Placing default value in the form fields
Permalink
I'm using the form builder with the addition of the Ajax Form add-on from jordanlev (kudos for that by the way jordan).
I have a really simple contact form in the footer of the site and I need to change the value attribute in one field and add a default piece of text in the textarea. So basically:
<input type="email" value="" id="Question1" name="Question1">
to this:
<input type="email" value="Email Address" id="Question1" name="Question1">
And the text area from: <textarea style="width:95%" rows="3" cols="50" id="Question2" name="Question2"></textarea>
To this:
<textarea style="width:95%" rows="3" cols="50" id="Question2" name="Question2">Message</textarea>
Where and what do I need to change these default values?
Thanks in advance for any pointers...
Cheers - Ben
I have a really simple contact form in the footer of the site and I need to change the value attribute in one field and add a default piece of text in the textarea. So basically:
<input type="email" value="" id="Question1" name="Question1">
to this:
<input type="email" value="Email Address" id="Question1" name="Question1">
And the text area from: <textarea style="width:95%" rows="3" cols="50" id="Question2" name="Question2"></textarea>
To this:
<textarea style="width:95%" rows="3" cols="50" id="Question2" name="Question2">Message</textarea>
Where and what do I need to change these default values?
Thanks in advance for any pointers...
Cheers - Ben
No, ended up doing it with jQuery (far from ideal but my PHP powers are weak)
Hi I have managed to get this working... in a way... here goes...
from the file /concrete/core/controllers/blocks/form_minisurvey.php
Copy the function including lines 264-285 ish, into your custom form block controller
Then change the instances of $val to $questionData['question']
This will then put your question title as the default "value", you maybe able to play with this to get another result, but thats all i needed to do.
Hope it helps
Ben
from the file /concrete/core/controllers/blocks/form_minisurvey.php
Copy the function including lines 264-285 ish, into your custom form block controller
case 'text': $val=($_REQUEST['Question'.$msqID])?Loader::helper('text')->entities($_REQUEST['Question'.$msqID]):''; return '<textarea name="Question'.$msqID.'" id="Question'.$msqID.'" cols="'.$questionData['width'].'" rows="'.$questionData['height'].'" style="width:95%">'.$val.'</textarea>'; case 'url': $val=($_REQUEST['Question'.$msqID])?$_REQUEST['Question'.$msqID]:''; return '<input name="Question'.$msqID.'" id="Question'.$msqID.'" type="url" value="'.stripslashes(htmlspecialchars($val)).'" />'; case 'telephone': $val=($_REQUEST['Question'.$msqID])?$_REQUEST['Question'.$msqID]:''; return '<input name="Question'.$msqID.'" id="Question'.$msqID.'" type="tel" value="'.stripslashes(htmlspecialchars($val)).'" />'; case 'email': $val=($_REQUEST['Question'.$msqID])?$_REQUEST['Question'.$msqID]:''; return '<input name="Question'.$msqID.'" id="Question'.$msqID.'" type="email" value="'.stripslashes(htmlspecialchars($val)).'" />'; case 'date': $val=($_REQUEST['Question'.$msqID])?$_REQUEST['Question'.$msqID]:''; return $datetime->date('Question'.$msqID,($val!==''?$val:'now'));
Viewing 15 lines of 22 lines. View entire code block.
Then change the instances of $val to $questionData['question']
This will then put your question title as the default "value", you maybe able to play with this to get another result, but thats all i needed to do.
Hope it helps
Ben
I love making sites for Concrete5 but the control and styling of forms is a lot less flexible than I'd like.
My best option ishttps://github.com/jordanlev/c5_custom_contact_form... but that's still not really what you were looking for when you posted this...