[SOLVED] <?= $sendmail_form ?> From Contact Owner Module (misc info and tweaks)

tonycajjo

Joined: 2009-07-18
Posts: 35
Posted: Thu, 2013-10-24 03:55

So when using the Contact Owner Module, the TO: Field is not used so i want to put a value in there and make it read only. The only problem is all the code is:

Quote:
<?= $sendmail_form ?>

I can change it to:

Quote:
<form id="g-contact-owner-send-form" method="post" action="/index.php/contactowner/sendemail/-1">
<input type="hidden" value="Some Random Numbers/Letters" name="csrf">
<fieldset>
<legend></legend>
<ul>
<li>
<label for="email_to">To:</label>
<input id="g-contactowner-to-name" class="textbox" type="text" value="Owner Name" name="email_to" readonly="readonly"(or even make it hidden)>
</li>
<li>
<label for="email_from">From:</label>
<input id="g-contactowner-from-email" class="textbox" type="text" value="Your email here." name="email_from">
</li>
<li>
<label for="email_subject">Subject:</label>
<input id="g-contactowner-subject" class="textbox" type="text" value="" name="email_subject">
</li>
<li>
<label for="email_body">Message:</label>
<textarea id="g-contactowner-email-body" class="textarea" cols="" rows="" name="email_body"></textarea>
</li>
<li>
<input class="submit ui-state-default ui-corner-all" type="submit" value="Send" name="SendMessage">
</li>
</ul>
</fieldset>
</form>

but then i have the token value up there. Is this necessary? can i just remove that input line all together? or is is need for cookies or something to make the email work. just trying to understand.

where can i find the default code for the sendmail_form, maybe that has my answer? i can take that, paste it in the contactowner_emailform.html.php file and be on my way. maybe some php that will generate the token?

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Thu, 2013-10-24 15:11

I don't understand what you want to do here.
The default form is generated by the get_email_form function in /contollers/contactowner.php
do you want to disable the editing of one form field? if so just add:
->disabled(true);

If you need to csrf token it is :
$csrf = access::csrf_token();
and can be used like:
<?= $csrf ?>

Hope that helps.

Dave

_____________________________________________
Blog & G2 || floridave - Gallery Team

 
tonycajjo

Joined: 2009-07-18
Posts: 35
Posted: Sat, 2013-10-26 17:51

thank you for the reply.
The <?= $csrf ?> tag also worked to generate a random csrf (though i am not 100% sure what it's used for) but i didnt go that route.

I have added the ->disabled(true); in the contactowner.php file where the form is being built and that accomplishes what i wanted, cause regardless of what the visitor changed it to the email would always go to the Owner, so i thought it odd to allow that field to be editable. what is the -> called? i want to add an "onclick" event for the from email, but not sure how to research the onclick for this type of form building. (i.e. for the from email, ->onclick="this.value='';"

anyhow, i can modify the g-contactowner-to-name css to change it's appearance. (or add it cause i cent find it anywhere in the css files.)

Thanks again.

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Sun, 2013-10-27 05:10
Quote:
what is the -> called

Not sure. It is part of the forge form generation of kohana.
You could add:
->id("someid")
to the field and then use jquery to listen for the click. Add the JS to the view file.

I do that in the admin form of the carousel module. Forge does not have radio buttons that I know so I use checkboxes and toggle the checkboxes with JS using the id of the form field.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
tonycajjo

Joined: 2009-07-18
Posts: 35
Posted: Tue, 2013-10-29 03:04

Thank you.

i was able to add:

Quote:
->onClick("ClearFrom();");

getting it to execute that function, then to the .php file then in the view file added:

Quote:
<script>
function ClearFrom()
{
if (document.getElementById("g-contactowner-from-email").value=="Your email Address Here")
{

document.getElementById("g-contactowner-from-email").value= "";
}
}
</script>

I added the if statement cause i only want it to clear on the first click, and on the first click that is the default value there.

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Tue, 2013-10-29 04:14

Glad you got it all sorted and posted back to the community for others.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
randy9000

Joined: 2012-05-17
Posts: 16
Posted: Mon, 2013-12-09 01:24

Hi,

Is there a way to add Reply-to logic to the email that is sent out with via the Contact Owner email?

Please help.

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Mon, 2013-12-09 03:49

I'm not sure I 100% understand what you are after and what 'logic' you need but see if this works:
Edit contactowner/controllers/contactowner.php find:

        Sendmail::factory()
          ->to($str_emailto)
          ->subject($str_emailsubject)
          ->header("Mime-Version", "1.0")
          ->header("Content-type", "text/html; charset=utf-8")
          ->message($str_emailbody)
          ->send();

and change to:

        Sendmail::factory()
          ->to($str_emailto)
          ->subject($str_emailsubject)
          ->header("Mime-Version", "1.0")
          ->header("Content-type", "text/html; charset=utf-8")
          ->reply_to("example@example.com")
          ->message($str_emailbody)
          ->send();

Does that work? I did not test.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team