Event on Select fields ckForms 1.3.5

Questions and bug reports for current release of CKForms

Event on Select fields ckForms 1.3.5

Postby jrivero » Wed Sep 29, 2010 8:17 pm

For my site I needed to be able to control the onChange and onClick events of some form fields. So, I've implemented it, changing the following files:

Administration:
"administrator/components/com_ckforms/views/ckfield/tmpl/ckfield_tpl.php" at line 466
Code: Select all
<tr>
    <td class="key"><label for="title"><?php echo JText::_( 'Event' ); ?>:</label></td>
    <td ><input type="text" name="ckEvent" id="ckEvent" value="<?php if (Isset($this->ckfield->ckEvent)) echo $this->ckfield->ckEvent; ?>" /></td>
</tr>
<tr>
    <td class="key"><label for="title"><?php echo JText::_( 'Function' ); ?>:</label></td>
    <td><input type="text" name="ckFunction" id="ckFunction" value="<?php if (Isset($this->ckfield->ckFunction)) echo $this->ckfield->ckFunction; ?>" /></td>
</tr>


"administrator/components/com_ckforms/tables/ckfield.php" at line 112

Code: Select all
   var $ckEvent= null;   
   var $ckFunction= null;


Front-end

"component/ck_forms/views/ckforms/tmpl/default.php" at line 415
Code: Select all
<select class="<?php echo $validationclass; ?> ckCSSinput <?php echo $field->fieldCSSclass; ?>" name="<?php echo $field->name; ?>[]" size="<?php echo $field->t_heightS; ?>" <?php if ($field->t_multipleS == '1') { ?> multiple<?php } ?> <?php if ($field->readonly == "1") {echo ' readonly="true"';} ?> <?php if(isset($field->ckEvent) && isset($field->ckFunction)){ echo $field->ckEvent.'="'.$field->ckFunction.'"'; } ?> >


To support this, I've also modified the database, by adding two columns in the 'jos_ckfields' table. I called them ckEvent(text) and ckFunction(text).
You can use this script to update your db:
Code: Select all
alter table jos_ckfields add column ckEvent text, add column ckFunction text


The javascript functions called by the events should be in the file "component/ck_forms/views/ckforms/tmpl/default.php".

This implementation adds two text fields in Add field form (only when adding a select field), that allows the user to insert the name of the event (onchange, onclick, etc) and the js action involved (for example: javascript:form.submit();). Actually these fields are added as attributes of the select field, so they can be any other attribute that you want (the first field is the name and the second one is the value). Both fields are required in other to add the attribute (i.e. you wouldn't be able to add a name without a value and viceversa).


I hope that this contribution is helpful
User avatar
jrivero
 
Posts: 2
Joined: Wed Sep 29, 2010 4:30 pm
Top

Re: Event on Select fields ckForms 1.3.5

Postby Designinja » Fri Nov 05, 2010 2:21 pm

Good news is that I tried this and it worked perfectly a described. Thankyou! :)

Bad news is that I didn't read closely enough that it only applied to select fields (yeah, I know... it's in the title!). On my site I need this for email and submit fields.

Does anyone know if it would take much to adapt this to email / submit fields or is this kind of feature coming to 1.3.6?
Designinja
 
Posts: 1
Joined: Fri Nov 05, 2010 11:53 am
Top


Return to CKForms 1.3.x Support forum

Who is online

Users browsing this forum: No registered users and 0 guests