I'd like to know if anyone can help me on customizing the contact us page.
I'd like to add text to the end of the page (address phones etc.)
How can we add new text fields on the form ?
==================================================
Well there are two ways to do this. One requires a bit of programming. Modifying the custom module to do the work for you. I think I will leave that to the admin of this forum to do a how to on that. The quickest way is not always the best in the long term. However let me give you the quick way. You just have to watch your updates to ensure that is doesn't change your "additions" to your form.
You can open /protected/modules/base/worklets/WBaseContact.php. You will see the following:
To add text you can add as part of the elements section like the following:
Add as many lines as you want.
Now to add text fields you have to not only change here by adding a in the elements array:
But to get it to work properly you will have to change the following script:
/protected/modules/base/models/MBaseContactForm.php and find the following:
And for the new_field add as following:
Then at the top of the script you need to add the new field like:
This is not tested code. I have done similar. You may have to play with it. However as I stated earlier you will have to monitor changes to these two scripts as updates occur.
If this doesn't work let me know. I will modify what I have posted.
Now this will change the base contact page. If you need a new contact page then that is a different process.
I'd like to add text to the end of the page (address phones etc.)
How can we add new text fields on the form ?
==================================================
Well there are two ways to do this. One requires a bit of programming. Modifying the custom module to do the work for you. I think I will leave that to the admin of this forum to do a how to on that. The quickest way is not always the best in the long term. However let me give you the quick way. You just have to watch your updates to ensure that is doesn't change your "additions" to your form.
You can open /protected/modules/base/worklets/WBaseContact.php. You will see the following:
PHP Code:
public function properties()
{
return array(
'elements' => array(
'name' => array('type' => 'text'),
'email' => array('type' => 'text'),
'subject' => array('type' => 'text'),
'message' => array('type' => 'textarea'),
),
'buttons' => array(
'submit' => array('type' => 'submit',
'label' => $this->t('Send'))
),
'model' => $this->model
);
}
PHP Code:
public function properties()
{
return array(
'elements' => array(
'name' => array('type' => 'text'),
'email' => array('type' => 'text'),
'subject' => array('type' => 'text'),
'message' => array('type' => 'textarea'),
'<br/><h4> Our Address </h4><br/>',
'123 High Street<br/>',
'Somewhere, OT 12345',
),
'buttons' => array(
'submit' => array('type' => 'submit',
'label' => $this->t('Send'))
),
'model' => $this->model
);
}
Now to add text fields you have to not only change here by adding a in the elements array:
PHP Code:
'new_field' => array('type' => 'text'),
/protected/modules/base/models/MBaseContactForm.php and find the following:
PHP Code:
public function attributeLabels()
{
return array(
'name' => $this->t('Full Name'),
'email' => $this->t('Email Address'),
'subject' => $this->t('Subject'),
'message' => $this->t('Message'),
);
}
PHP Code:
public function attributeLabels()
{
return array(
'name' => $this->t('Full Name'),
'email' => $this->t('Email Address'),
'subject' => $this->t('Subject'),
'message' => $this->t('Message'),
'new_field' => $this->t('My new field label/text'),
);
}
PHP Code:
public $name;
public $email;
public $subject;
public $message;
public $new_field; // New Field Added
If this doesn't work let me know. I will modify what I have posted.
Now this will change the base contact page. If you need a new contact page then that is a different process.
No comments:
Post a Comment