It looks like you're new here. If you want to get involved, click one of these buttons!
$fields = array();
$upload_path = assets_server_path().'uploads/';
$fields['name'] = array('required' => TRUE, 'label' => 'Your Name','class' => 'required" minlength="2');
$fields['email'] = array('required' => TRUE, 'class' => 'required email" autocapitalize="off" autocorrect="off');
$fields['phone'] = array('required' => TRUE, 'class' => 'required phone');
$fields['drawings'] = array('label' => 'Drawings','type' => 'file', 'allow' => 'pdf,ai,dwg','multiple' => TRUE, 'upload_path' => $upload_path);
//$fields['message'] = array('type' => 'textarea', 'cols' => 45,'required' => TRUE, 'class' => 'textarea', 'class' => 'required');
$this->form_builder->set_fields($fields);
// will set the values of the fields if there is an error... must be after set_fields
$this->form_builder->set_validator($this->validator);
$this->form_builder->form_attrs = 'data-ajax="false" action="" id="request_form" method="POST"';
$this->form_builder->set_field_values($_POST);
$this->form_builder->display_errors = TRUE;
$this->form_builder->required_indicator = '';
$this->form_builder->label_layout = 'top';
$this->form_builder->submit_value = '<input type="submit" value="Send" name="submit" data-inline="true" data-theme="d" >';
$this->form_builder->id = 'form';
$vars['form'] = $this->form_builder->render();
// use Fuel_page to render so it will grab all opt-in variables and do any necessary parsing
$this->fuel->pages->render('request', $vars,array('render_mode' => 'cms'));
Comments
I could do it easily enough in the JavaScript, but wanted it more self-contained.
$this->form_builder->load_custom_fields(APPPATH.'config/custom_fields.php');
There is a "data" type attribute you can use which takes an array of "data" type attributes to append to the element.
And it was right there in the instructions I was staring at... sheesh.
<script type="text/javascript"> var jqx_config = {}; jqx_config.localized = {"label_search":"Search...","btn_save":"Save","btn_cancel":"Cancel","btn_add":"Add","btn_edit":"Edit","btn_select":"Select","btn_asset":"Asset","btn_image":"Image","btn_pdf":"PDF","btn_flash":"Flash","btn_upload_asset":"Upload Asset","btn_view_source":"Source","btn_view_editor":"Editor","btn_preview":"Preview","btn_select_all":"Select All","btn_deselect_all":"Deselect All","comboselect_values_empty":"There are no more values to select","comboselect_selected_empty":"Select from the values on the left","comboselect_filter":"Filter your search","tree_orphans":"_orphans","confirm_delete":"Are you sure you want to delete this?","form_label_send_email_notification":"Send password update email notification?","error_importing_ajax":"Error importing view file","viewpage_close":"Close","viewpage_new_window":"New Window","rearrange_on":"You can change the precedence order by selecting and dragging the data rows below.","replace_warning":"Are you sure you want to replace the contents of this record?","edit_multi_select_warning":"You must have only have one option selected to edit.","markitup_b":"Bold","markitup_i":"Italic","markitup_strike":"Stroke Through","markitup_p":"Paragraph","markitup_h1":"Heading 1","markitup_h2":"Heading 2","markitup_h3":"Heading 3","markitup_h4":"Heading 4","markitup_ul":"Bullet List","markitup_ol":"Numeric List","markitup_li":"List Item","markitup_blockquote":"Block Quote","markitup_hr":"Horizontal Rule","markitup_img":"Image","markitup_link":"Link","markitup_target":"Target","markitup_title":"Title","markitup_mailto":"Mailto","markitup_php":"PHP Variable","markitup_clean":"Clean","markitup_preview":"Preview Toggle (hold down alt\/option and click to preview)","markitup_fullscreen":"Full Screen","markitup_placeholder_headings":"Your title here...","markitup_placeholder_link":"Your text to link...","markitup_email":"email@address.com","markitup_fullscreen_close":"Close","warn_before_delete_msg":"Are you sure you want to delete this item?","btn_add_another":"Add Another","btn_remove":"Remove"}; var __FUEL_LOCALIZED__ = {"label_search":"Search...","btn_save":"Save","btn_cancel":"Cancel","btn_add":"Add","btn_edit":"Edit","btn_select":"Select","btn_asset":"Asset","btn_image":"Image","btn_pdf":"PDF","btn_flash":"Flash","btn_upload_asset":"Upload Asset","btn_view_source":"Source","btn_view_editor":"Editor","btn_preview":"Preview","btn_select_all":"Select All","btn_deselect_all":"Deselect All","comboselect_values_empty":"There are no more values to select","comboselect_selected_empty":"Select from the values on the left","comboselect_filter":"Filter your search","tree_orphans":"_orphans","confirm_delete":"Are you sure you want to delete this?","form_label_send_email_notification":"Send password update email notification?","error_importing_ajax":"Error importing view file","viewpage_close":"Close","viewpage_new_window":"New Window","rearrange_on":"You can change the precedence order by selecting and dragging the data rows below.","replace_warning":"Are you sure you want to replace the contents of this record?","edit_multi_select_warning":"You must have only have one option selected to edit.","markitup_b":"Bold","markitup_i":"Italic","markitup_strike":"Stroke Through","markitup_p":"Paragraph","markitup_h1":"Heading 1","markitup_h2":"Heading 2","markitup_h3":"Heading 3","markitup_h4":"Heading 4","markitup_ul":"Bullet List","markitup_ol":"Numeric List","markitup_li":"List Item","markitup_blockquote":"Block Quote","markitup_hr":"Horizontal Rule","markitup_img":"Image","markitup_link":"Link","markitup_target":"Target","markitup_title":"Title","markitup_mailto":"Mailto","markitup_php":"PHP Variable","markitup_clean":"Clean","markitup_preview":"Preview Toggle (hold down alt\/option and click to preview)","markitup_fullscreen":"Full Screen","markitup_placeholder_headings":"Your title here...","markitup_placeholder_link":"Your text to link...","markitup_email":"email@address.com","markitup_fullscreen_close":"Close","warn_before_delete_msg":"Are you sure you want to delete this item?","btn_add_another":"Add Another","btn_remove":"Remove"}; jqx_config.assetsAccept = 'jpg|jpeg|gif|png'; jqx_config.editor = 'markitup'; // if you use the texarea fields this must be named </script> <?=js(array('fuel' => 'jqx/jqx.js')).js(array('fuel' => 'fuel/global.js')).js(array('fuel' => 'jquery/plugins/jquery.form'))?>
I would suggest adding that in an if statement which determines if the page NEEDS to use the forms. ie. if (strtolower(uri_segment(1)) == 'formpage')
I love that as I'm learning more it's coming together so much easier. The learning curve is huge, but the payoff is incredible!
Again, thanks for sharing Fuel David!
<script> <?php $this->load->module_view(FUEL_FOLDER, '_blocks/fuel_header_jqx'); ?> </script> <?php echo js('fuel/global', 'fuel')?> <?php echo js('jquery/plugins/jquery-ui-1.8.17.custom.min', 'fuel'); ?>
Below is the CSS that may need to be included:
<?=css('jqmodal, jquery.tooltip, jquery.treeview, fuel-theme/jquery-ui-1.8.17.custom, fuel', 'fuel')?>
Umm, I found a problem with the way I was using custom_fields.php. Is there a specific spot to put my own custom field types, or should they just go in fuel\modules\fuel\libraries\Fuel_custom_fields.php ?
It was working on the front end PERFECTLY the way I had it, but as soon as I try to use the back end it messed up the forms section terribly.
I tried creating \fuel\application\libraries\MY_custom_fields.php but even with my custom_field as such:
$fields['request_checkbox'] = array( 'class' => array('app' => 'libraries/MY_custom_fields'), 'css_class' => 'request_checkbox', 'function' => 'request_checkbox' );
it couldn't find the class in the libraries section.
I put my function in Fuel_custom_fields.php like such:
function request_checkbox($params) { $form_builder =& $params['instance']; $str = $form_builder->create_checkbox($params).' <label for="'.$params['name'].'">'.$params['label'].'</label><br /><br />'; return $str; }
And this comes up with some frustrating errors.
Is there's a better way?
thanks.
I put my functions in my controller file outside of the class and removed the $fields[] array in MY_custom_fields.php
Seems okay so far.
$fields['request_checkbox'] = array(
'class' => array('app' => 'libraries/MY_custom_fields'),
'css_class' => 'request_checkbox',
'function' => 'request_checkbox'
);