0

I have a content type that want to display it's form in block to any user types but when putting the form fields in my custom form style the form doesn't save any data although there are the required render items inside my custom form .tpl file

<?php print drupal_render($form['form_build_id']); ?>
<?php print drupal_render($form['form_id']); ?>
<?php print drupal_render($form['form_token']); ?>

All of the form configuration to appear to the has been added but the problem in form saving.

<h3>
    <i class='sprite blue-circle'></i>

</h3>  
<!-- -->
<div class="row">
  <div class="calc-header">

  </div>
  <div class="installment">
    <div class="col-sm-6 car-price calc-wrapper">
      <table border="true" cellpadding="0">
        <tr>
          <td class='table-form-lable'>
            <label for="">

            </label>
          </td>
          <td> 
            <label > 
              <input type="radio" id="edit-field-installment-car-state-und-" name="field_installment_car_state[und]" value=""  >  
            </label>
            <label > 
              <input type="radio" id="edit-field-installment-car-state-und---2" name="field_installment_car_state[und]" value="" checked="checked"  >  
            </label>
          </td>
          <td class='required-cell'>
            <img src="<?php print base_path().path_to_theme().'/'; ?>images/required-field-icon-red.png">
          </td>
        </tr>
      </table>
    </div>
    <div class="col-sm-6 car-price calc-wrapper">
      <table border="true" cellpadding="0">
        <tr>
          <td class='table-form-lable'>
            <label for="">

            </label>
          </td>
          <td> 
              <label>
                <input type="radio" id="edit-field-installment-process-type-und-" name="field_installment_process_type[und]" value=""  >  
              </label>
              <label>
                <input type="radio" id="edit-field-installment-process-type-und---2" name="field_installment_process_type[und]" value="" checked="checked" >  
              </label>
          </td>  
          <td class='required-cell'>
            <img src="<?php print base_path().path_to_theme().'/'; ?>images/required-field-icon-red.png">
          </td>
        </tr>
      </table>
    </div> 
    <div class="clearfix"> </div>
    <div class="col-sm-6 car-price calc-wrapper">
      <table border="true" cellpadding="0">
        <tr>
          <td class='table-form-lable'>
            <label for="">

            </label>
          </td>
          <td> 
            <input id="car_type" type="text" name="field_installment_car_type[und][0][value]" value="" placeholder="" required  >
          </td>
          <td class='required-cell'>
            <img src="<?php print base_path().path_to_theme().'/'; ?>images/required-field-icon-red.png">
          </td>
        </tr>
      </table>
    </div>
    <div class="col-sm-6 car-price calc-wrapper">
      <table border="true" cellpadding="0">
        <tr>
          <td class='table-form-lable'>
            <label for="">

            </label>
          </td>
          <td> 
              <input id="manf_year" type="number" name="field_installment_manf_year[und][0][value]" value="" placeholder="" required  > 
          </td>  
          <td class='required-cell'>
            <img src="<?php print base_path().path_to_theme().'/'; ?>images/required-field-icon-red.png">
          </td>
        </tr>
      </table>
    </div> 
    <div class="clearfix"> </div>
    <div class="col-sm-6 car-price calc-wrapper">
      <table border="true" cellpadding="0">
        <tr>
          <td class='table-form-lable'>
            <label for="">

            </label>
          </td>
          <td> 
            <input id="car_value" type="number" name="field_installment_value[und][0][value]" value="" placeholder="" required  > 
          </td>
          <td class='required-cell'>
            <img src="<?php print base_path().path_to_theme().'/'; ?>images/required-field-icon-red.png">
          </td>
        </tr>
      </table>
    </div>
    <div class="col-sm-6 car-price calc-wrapper">
      <table border="true" cellpadding="0">
        <tr>
          <td class='table-form-lable'>
            <label for="">

            </label>
          </td>
          <td> 
              <input id="period" type="number" name="field_installment_period[und][0][value]" value="" placeholder="" required  >
          </td>  
          <td class='required-cell'>
            <img src="<?php print base_path().path_to_theme().'/'; ?>images/required-field-icon-red.png">
          </td>
        </tr>
      </table>
    </div> 
    <div class="clearfix"> </div>
  </div>
</div>
<br />
<br />
<div class="row">
  <div class="calc-header">

  </div>
  <div class="installment">
    <!-- First row -->
    <div class="col-sm-6 car-price calc-wrapper">
      <table border="true" cellpadding="0">
        <tr>
          <td class='table-form-lable'>
            <label for="">

            </label>
          </td>
          <td> 
            <input id="name" type="text" name="field_installment_name[und][0][value]" value="" placeholder="" required  >
          </td>
          <td class='required-cell'>
            <img src="<?php print base_path().path_to_theme().'/'; ?>images/required-field-icon-red.png">
          </td>
        </tr>
      </table>
    </div>
    <div class="col-sm-6 car-price calc-wrapper">
      <table border="true" cellpadding="0">
        <tr>
          <td class='table-form-lable'>
            <label for="">

            </label>
          </td>
          <td> 
           <!-- <span>
            <label >
              <input type="radio" name="field_installment_gender[und]" value="" checked>

            </label>
            <label >
              <input type="radio" name="field_installment_gender[und]" value="">

            </label> -->
           </span>
          </td>  
          <td class='required-cell'>
            <img src="<?php print base_path().path_to_theme().'/'; ?>images/required-field-icon-red.png">
          </td>
        </tr>
      </table>
    </div> 
    <div class="clearfix"> </div>
    <div class="col-sm-6 car-price calc-wrapper">
      <table border="true" cellpadding="0">
        <tr>
          <td class='table-form-lable'>
            <label for="">

            </label>
          </td>
          <td> 
            <input id="nationality" type="text" name="field_installment_nationality[und][0][value]" value="" placeholder="" required  > 
          </td>
          <td class='required-cell'>
            <img src="<?php print base_path().path_to_theme().'/'; ?>images/required-field-icon-red.png">
          </td>
        </tr>
      </table>
    </div>
    <div class="col-sm-6 car-price calc-wrapper">
      <table border="true" cellpadding="0">
        <tr>
          <td class='table-form-lable'>
            <label for="">

            </label>
          </td>
          <td> 
             <input id="age" type="number" name="field_installment_age[und][0][value]" value="" placeholder="" required  >
          </td>  
          <td class='required-cell'>
            <img src="<?php print base_path().path_to_theme().'/'; ?>images/required-field-icon-red.png">
          </td>
        </tr>
      </table>
    </div> 
    <div class="clearfix"> </div>
    <div class="col-sm-6 car-price calc-wrapper">
      <table border="true" cellpadding="0">
        <tr>
          <td class='table-form-lable'>
            <label for="">

            </label>
          </td>
          <td> 
            <input id="comm_record_num" type="text" name="field_installment_location[und][0][value]" value="" placeholder="" required  >
          </td>
          <td class='required-cell'>
            <img src="<?php print base_path().path_to_theme().'/'; ?>images/required-field-icon-red.png">
          </td>
        </tr>
      </table>
    </div>
    <div class="col-sm-6 car-price calc-wrapper">
      <table border="true" cellpadding="0">
        <tr>
          <td class='table-form-lable'>
            <label for="">

            </label>
          </td>
          <td> 
             <input id="source" type="text" name="field_installment_source[und][0][value]" value="" placeholder="" required  > 
          </td>  
          <td class='required-cell'>
            <img src="<?php print base_path().path_to_theme().'/'; ?>images/required-field-icon-red.png">
          </td>
        </tr>
      </table>
    </div> 
    <div class="clearfix"> </div>

    <div class="col-sm-6 car-price calc-wrapper">
      <table border="true" cellpadding="0">
        <tr>
          <td class='table-form-lable'>
            <label for="">

            </label>
          </td>
          <td> 
            <input id="work_palce" type="text" name="field_installment_work_destinatin[und][0][value]" value="" placeholder=" " required  > 
          </td>
          <td class='required-cell'>
            <img src="<?php print base_path().path_to_theme().'/'; ?>images/required-field-icon-red.png">
          </td>
        </tr>
      </table>
    </div>
    <div class="col-sm-6 car-price calc-wrapper">
      <table border="true" cellpadding="0">
        <tr>
          <td class='table-form-lable'>
            <label for="">

            </label>
          </td>
          <td> 
             <input id="job_name" type="text" name="field_installment_job_name[und][0][value]" value="" placeholder="" required  >
          </td>  
          <td class='required-cell'>
            <img src="<?php print base_path().path_to_theme().'/'; ?>images/required-field-icon-red.png">
          </td>
        </tr>
      </table>
    </div> 
    <div class="clearfix"> </div>

    <div class="col-sm-6 car-price calc-wrapper">
      <table border="true" cellpadding="0">
        <tr>
          <td class='table-form-lable'>
            <label for="">

            </label>
          </td>
          <td> 
            <input id="service_period" type="number" name="field_installment_service_period[und][0][value]" value="" placeholder="" required  >
          </td>
          <td class='required-cell'>
            <img src="<?php print base_path().path_to_theme().'/'; ?>images/required-field-icon-red.png">
          </td>
        </tr>
      </table>
    </div>
    <div class="col-sm-6 car-price calc-wrapper">
      <table border="true" cellpadding="0">
        <tr>
          <td class='table-form-lable'>
            <label for="">
                             </label>
          </td>
          <td> 
             <input id="total_salary" type="number" name="field_installment_total_salary[und][0][value]" value="" placeholder="">
          </td>  
          <td class='required-cell'>
            <img src="<?php print base_path().path_to_theme().'/'; ?>images/required-field-icon-red.png">
          </td>
        </tr>
      </table>
    </div> 
    <div class="clearfix"> </div>

    <div class="col-sm-6 car-price calc-wrapper">
      <table border="true" cellpadding="0">
        <tr>
          <td class='table-form-lable'>
            <label for="">

            </label>
          </td>
          <td> 
            <input id="mobile" type="tel" name="field_installment_mobile[und][0][value]" value="" placeholder="" required  > 
          </td>
          <td class='required-cell'>
            <img src="<?php print base_path().path_to_theme().'/'; ?>images/required-field-icon-red.png">
          </td>
        </tr>
      </table>
    </div>
    <div class="col-sm-6 car-price calc-wrapper">
      <table border="true" cellpadding="0">
        <tr>
          <td class='table-form-lable'>
            <label for="">

            </label>
          </td>
          <td> 
             <input id="total_salary" type="number" name="field_installment_total_salary[und][0][value]" value="" placeholder=" ">
          </td>  
          <td class='required-cell'>
            <img src="<?php print base_path().path_to_theme().'/'; ?>images/required-field-icon-red.png">
          </td>
        </tr>
      </table>
    </div> 
    <div class="clearfix"> </div>

    <div class="col-sm-6 car-price calc-wrapper">
      <table border="true" cellpadding="0">
        <tr>
          <td class='table-form-lable'>
            <label for="">

            </label>
          </td>
          <td> 
             <input type="checkbox" name="field_installment_income" value="" checked>
             <?php  //print render($field_installment_income); ?>
          </td>
          <td class='required-cell'>
            <img src="<?php print base_path().path_to_theme().'/'; ?>images/required-field-icon-red.png">
          </td>
        </tr>
      </table>
    </div>
    <div class="col-sm-6 car-price calc-wrapper">
      <table border="true" cellpadding="0">
        <tr>
          <td class='table-form-lable'>
            <label for="">

            </label>
          </td>
          <td> 
             <input id="income" type="text" name="field_installment_remember[und][0][value]" value="" placeholder=" " required  >
          </td>  
          <td class='required-cell'>
            <img src="<?php print base_path().path_to_theme().'/'; ?>images/required-field-icon-red.png">
          </td>
        </tr>
      </table>
    </div> 
    <div class="clearfix"> </div>

     <div class="col-sm-6 car-price calc-wrapper">
      <table border="true" cellpadding="0">
        <tr>
          <td class='table-form-lable'>
            <label for="">

            </label>
          </td>
          <td> 
              <label >
                <input type="radio" id="edit-field-installment-maritul-status-und-" name="field_installment_maritul_status[und]" value="" >  

              </label>
              <label >
               <input type="radio" id="edit-field-installment-maritul-status-und---2" name="field_installment_maritul_status[und]" value="" checked="checked" > 

              </label>
          </td>
          <td class='required-cell'>
            <img src="<?php print base_path().path_to_theme().'/'; ?>images/required-field-icon-red.png">
          </td>
        </tr>
      </table>
    </div>
    <div class="col-sm-6 car-price calc-wrapper">
      <table border="true" cellpadding="0">
        <tr>
          <td class='table-form-lable'>
            <label for="">

            </label>
          </td>
          <td> 
             <input id="family_num" type="number" name="field_installment_family_num[und][0][value]" value="" placeholder=" " required  >
          </td>  
          <td class='required-cell'>
            <img src="<?php print base_path().path_to_theme().'/'; ?>images/required-field-icon-red.png">
          </td>
        </tr>
      </table>
    </div> 
    <div class="clearfix"> </div>
  </div>
</div>
<br>
<br>

<div class="row">
  <hr>
  <label class='checkbox'>
    <input type="checkbox" name="field_installment_validation[und]" value="" required >
    <?php  //print render($field_installment_validation); ?>


  </label>
  <br>
  <br>
  <div class="field pull-right span2"> <!-- <div class="pull-right"> -->
    <!-- <input id="submit" type="submit" name="submit" value="" class="btn"> -->
    <?php print drupal_render($form['form_build_id']); ?>
    <?php print drupal_render($form['form_id']); ?>
    <?php print drupal_render($form['form_token']); ?>
    <?php  //print render($actions); ?>
    <?php  print render($actions); ?>
  </div> 
</div>
  • Have you just created input elements in tpl files? It cannot work - from Drupal's point of view, what wasn't rendered using Form API, is not a genuine form element and will never be trusted / processed. – Mołot Dec 16 '13 at 16:03
  • 1
    Try adding <?php echo drupal_render_children($form); ?> right after <?php print render($actions); ?> – Clive Dec 16 '13 at 18:47
0

I would suggest that you call the drupal node form (as described here)

You can use hook_form_alter to unset the form elements you do not wish to appear, or set them to hidden.

You may wish to add a condition to assess the context of the form based on path or by testing for a configured context if you are using the context module. This will mean you can still get the full form on the node edit page.

| improve this answer | |
0

It's now working. I have followed the instructions related to theming a form in Drupal as follows:

  1. In template.php, I added all the form elements and removed all the input fields prefix and suffix, and used the following code

    function THEME_preprocess_[form_id]_form(&$variables) { 
      // Send all the form elements to the custom form file. 
    }
    
  2. in [form_id].tpl.php, I rendered the fields that I need by using the following code

    <?php print render($[field_name_sent_by_the_template_file]); ?>
    
| improve this answer | |
-1

I think you should use print drupal_render($form['actions']) instead of print render($actions);, I hope it helps.

| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.