Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function farm_quick_machinery_form($form, &$form_state){
- $form['quick_machinery'] = array(
- '#type'=>'fieldset',
- '#title' => t('Record machinery logs'),
- '#description' => t('Use this form to record machinery logs against equipment'),
- );
- $form['quick_machinery']['title'] = array(
- '#type' => 'textfield',
- '#title' => t('Log Name'),
- '#description' => t('The name of the log'),
- '#required' => TRUE,
- );
- $form['quick_machinery']['timestamp'] = array(
- '#type' => 'date_select',
- '#title' => t('Date'),
- '#date_format' => 'M j Y H:i',
- '#date_type' => DATE_FORMAT_UNIX,
- '#date_year_range' => '-10:+3',
- '#default_value' => REQUEST_TIME,
- '#required' => TRUE,
- );
- $form['quick_machinery']['asset'] = array(
- '#type'=>'textfield',
- '#title' => t('Equipment'),
- '#description' => t('Select the equipment the log is for'),
- '#autocomplete_path' => 'farm_asset/autocomplete/equipment',
- );
- $form['quick_machinery']['area']['name'] = array(
- '#type' => 'textfield',
- '#title' => t('Work Area'),
- '#description' => t('Enter the name of the area you worked in, and select it from the list that drops down'),
- '#autocomplete_path' => 'taxonomy/autocomplete/field_farm_area',
- '#required' => TRUE,
- );
- $form['quick_machinery']['description'] = array(
- '#type' => 'text_format',
- '#title' => t('Notes'),
- '#format' => 'farm_format',
- '#description' => t('Suggested things to record in the notes: <ul><li>Usage - Where it was used, what you did</li><li>Refuelled or oiled?</li><li>if any parts have been replaced</li></ul>'),
- );
- $form['quick_machinery']['hours'] = array(
- '#type' => 'textfield',
- '#title' => t('Hours on the clock'),
- '#description' => t('Hours on the hour meter on the machine, or the amount of time used for'),
- '#element_validate' => array('element_validate_number'),
- );
- $form['quick_machinery']['faultcheck'] = array(
- '#type'=> 'select',
- '#title' => t('Faults found?'),
- '#description' => t('Any issues identified with the machine? If yes, please list them below'),
- '#options' => array(0 => t('No'), 1 => t('Yes')),
- '#default_value'=>0,
- '#ajax'=>array(
- 'callback'=>'farm_quick_machinery_quick_form_faults_ajax',
- 'wrapper'=>'machinery-faults'
- ),
- );
- $form['quick_machinery']['fault'] = array(
- '#type'=>'container',
- '#prefix' => "<div id='machinery-faults'>Logs here",
- '#suffix'=>'</div>',
- );
- $checkbox = !empty($form_state['values']['faultcheck']) ? $form_state['values']['faultcheck'] : 0;
- if ($checkbox == 1){
- $form['quick_machinery']['fault']['faultform'] = array(
- '#type' => 'fieldset',
- '#title' => t('Fault reporting'),
- '#description' => t('Report any faults with equipment here'),
- );
- $form['quick_machinery']['fault']['faultform']['description'] = array(
- '#type'=>'textfield',
- '#title'=>'Fault details',
- '#description'=>t('Please enter details of the fault, including where it happened and how it happened.')
- );
- };
- return $form;
- }
- function farm_quick_machinery_quick_form_faults_ajax($form, &$form_state){
- return $form['quick_machinery']['fault'];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement