user177913
user177913

Reputation: 475

Form element validation error in CAKE PHP

I am new in cake php. I am working with getlancer script. I want to add a new field in project page. The field is a datepicker. The datepicker is working properly but the selected date of the datepicker is not passed to the controller at the time of page posting.

GETTING ERROR MESSAGE : Required11 as defined in model code.

Date Picker element creation code :

<div class="input text date-time select required validation:     {'message':'Required','allowEmpty':false,'rule':'notempty'}">
    <div class="js-datetime">
        <div class="js-cake-date">
        <?php echo $this->Form-input('pickupdate', array('label' => __l('Pick up date'), 'type' => 'date')); ?>
    </div>
    </div>
</div>

Model Code :

Array (
    'pickupdate' => array(
        'rule1' => array(
        'rule' => 'notempty',
        'message' => __l('Required11')
    ) ,
    'rule2' => array(
        'rule' => 'date',
        'message' => __l('Must be a valid date')
    )
)

Controller code:

$this->request->data['Project']['pickupdate'] = $this->request->data['Project']['pickupdate'];

Database table:

Field Name: pickupdate
Type: Date
Null: Yes
Default: Null

Rendered HTML for the Element :

<div class=”input text date-time select required validation:{'message':'Required','allowEmpty':false,'rule':'notempty'}”>

<div data-displayed="true" class="js-datetime xltriggered">
<div style="display: none;" class="js-cake-date">
<div class="input date required validation:{'rule2':{'rule':'date','message':'Must be a valid date'},'rule1':    {'rule':'empty','message':'Required11'}}"><label for="ProjectPickupdateMonth">Pick up date</label>    <select name="data[Project][pickupdate][month]" id="ProjectPickupdateMonth">
<option value="01">January</option>
<option value="02">February</option>
<option value="03">March</option>
<option value="04" selected="selected">April</option>
<option value="05">May</option>
<option value="06">June</option>
<option value="07">July</option>
<option value="08">August</option>
<option value="09">September</option>
<option value="10">October</option>
<option value="11">November</option>
<option value="12">December</option>
</select>-<select name="data[Project][pickupdate][day]" id="ProjectPickupdateDay">
<option value="01">1</option>
<option value="02">2</option>
<option value="03">3</option>
<option value="04">4</option>
<option value="05">5</option>
<option value="06">6</option>
<option value="07">7</option>
<option value="08">8</option>
<option value="09">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16" selected="selected">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
</select>-<select name="data[Project][pickupdate][year]" id="ProjectPickupdateYear">
<option value="2034">2034</option>
<option value="2033">2033</option>
<option value="2032">2032</option>
<option value="2031">2031</option>
<option value="2030">2030</option>
<option value="2029">2029</option>
<option value="2028">2028</option>
<option value="2027">2027</option>
<option value="2026">2026</option>
<option value="2025">2025</option>
<option value="2024">2024</option>
<option value="2023">2023</option>
<option value="2022">2022</option>
<option value="2021">2021</option>
<option value="2020">2020</option>
<option value="2019">2019</option>
<option value="2018">2018</option>
<option value="2017">2017</option>
<option value="2016">2016</option>
<option value="2015">2015</option>
<option value="2014" selected="selected">2014</option>
<option value="2013">2013</option>
<option value="2012">2012</option>
<option value="2011">2011</option>
<option value="2010">2010</option>
<option value="2009">2009</option>
<option value="2008">2008</option>
<option value="2007">2007</option>
<option value="2006">2006</option>
<option value="2005">2005</option>
<option value="2004">2004</option>
<option value="2003">2003</option>
<option value="2002">2002</option>
<option value="2001">2001</option>
<option value="2000">2000</option>
<option value="1999">1999</option>
<option value="1998">1998</option>
<option value="1997">1997</option>
<option value="1996">1996</option>
<option value="1995">1995</option>
<option value="1994">1994</option>
</select></div>                     </div>
<div id="datetimepicker1" class="input-append date datetimepicker"><input value="2014-04-17-19-01-PM" type="hidden"><label for="Pick up date">Pick up date</label><span class="add-onn top-smspace js-calender-block hor-space show-inline cur"><i data-time-icon="icon-time" data-date-icon="icon-calendar" class="icon-calendar text-16"></i> <span class="js-display-date">Apr 17, 2014</span></span><span class="info"></span></div></div></div>

Full Form code: add.ctp (if necessary)

<?php /* SVN: $Id: $ */ ?>
<div class="js-validation-part">

  <div class="projects form js-responses">
  <section class="row ver-space ver-smspace">
<?php if (!(isset($this->request->params['prefix']) and $this->request->params['prefix'] ==     'admin')) {?>
      <div class="tab-head bot-mspace text-13 clearfix"><h2 class="pull-left text-16 no-mar"><?php echo $this->Html->eAlt(ConstAltVerb::SingularCaps).' Control Panel';?></h2>
    <?php echo $this->element('employer-menu'); ?>
  </div>
<?php }?>

<h3 class="grayc"><?php echo __l('Post your project');?> </h3>

<?php echo $this->Form->create('Project', array('class' => 'form-horizontal js-upload-form', 'enctype' => 'multipart/form-data'));?>
    <fieldset>
        <h3 class="tab-head text-16 textn img-rounded"><?php echo __l('Type');?></h3>
        <div class="input radio radio-active-style top-mspace left-space">
            <?php  echo $this->Form->input('project_type_id', array('legend' => false,'type' => 'radio','class'=>'js-online','div' =>false));?>
            <div class="ver-space">
                <span class="help-block no-mar"><?php echo __l('Online:').' '.$this->Html->eAlt(ConstAltVerb::SingularCaps).' '.__l('or').' '.$this->Html->fAlt(ConstAltVerb::SingularSmall).' '.__l('can accomplish his/her job completely over net'); ?></span>
                <span class="help-block no-mar"> <?php echo __l('Offline:').' '.$this->Html->eAlt(ConstAltVerb::SingularCaps).' '.__l('or').' '.$this->Html->fAlt(ConstAltVerb::SingularSmall).' '.__l('needs to physically interact with each other'); ?></span>
            </div>
        </div>
    </fieldset>

    <fieldset>
    <?php
            if($this->Auth->user('role_id') == ConstUserTypes::Admin){
                echo $this->Form->input('user_id', array('label' => $this->Html->eAlt(ConstAltVerb::SingularCaps), 'empty' => __l('Please Select')));
            } ?>
        <h3 class="tab-head text-16 textn img-rounded"><?php echo __l('Info');?></h3>
        <div class="input text required ver-space">
          <?php echo $this->Form->input('name', array('label' => __l('Project Name'))); ?>
        </div>
        <div class="input textarea required">
          <?php echo $this->Form->input('description', array('type'=>'textarea','class' => 'js-description-count {"display":"js-description","field":"js-description-count","count":"'.Configure::read('Project.project_max_description_length').'"}','label'=>__l('Description'),'info'=>__l('Do not post any contact info. You can communicate with').' '.$this->Html->fAlt(ConstAltVerb::PluralCaps).' '.__l('on your project message board.').' <span class="character-info">'.__l('You have').' <span id="js-description-count"></span> '.__l('characters left').'</span>'));?>
         </div>
    </fieldset>
    <?php if(isPluginEnabled('ProjectCategory')): ?>
    <fieldset>
    <h3 class="tab-head text-16 textn img-rounded"><?php echo __l('Opportunity Type');?></h3>
    <div class="input select ver-space required validation:{'message':'Required','allowEmpty':false,'rule':'numeric'}">
      <?php echo $this->Form->input('project_category_id',array('multiple' => '','label' =>  __l('Opportunity Type'),'class'=>'span10','empty' => __l('Please Select')));?>

    <?php if(!empty($error)){?>
            <div class="error-message"><?php echo __l('Required'); ?></div>
        <?php } ?>
    </fieldset>
    <?php endif;?>
    <fieldset>

    <h3 class="tab-head text-16 textn img-rounded"><?php echo __l('Location');?></h3>
    <div class="mapblock-info">
        <div class="clearfix address-input-block">
        <?php
            echo $this->Form->input('address', array('type'=>'text','label' => __l('Address'), 'id' => 'ProjectAddress','class'=>'js-offline address-error-message')); ?>
        </div>
        <?php   echo $this->Form->input('latitude', array('id' => 'latitude', 'type' => 'hidden'));
            echo $this->Form->input('longitude', array('id' => 'longitude', 'type' => 'hidden'));
            echo $this->Form->input('country_id',array('class'=>'js-address','id'=>'js-country_id','type' => 'hidden'));
            echo $this->Form->input('State.name', array('type' => 'hidden'));
            echo $this->Form->input('City.name', array('type' => 'hidden'));
        ?>
        <div id="address-info" class="hide"><?php echo __l('Please select correct address value'); ?></div>
        <div id="mapblock">
            <div id="mapframe">
                <div id="mapwindow"></div>
            </div>
        </div>
    </div>
    </fieldset>
    <fieldset>
        <h3 class="tab-head text-16 textn img-rounded"><?php echo __l('Range');?></h3>
        <div class="input select required ver-space">
            <?php
            echo $this->Form->input('project_range_id', array('label' => __l('Project Budget'),'empty' => __l('Please Select')));
            $class='';
            if (empty($this->request->data['Project']['project_range_id']) || (!empty($this->request->data['Project']['project_range_id']) &&       $this->request->data['Project']['project_range_id'] !='custom')):
                $class ='hide';
            endif;
        ?>
        </div>
        <div class="input text required">
            <div class="<?php echo $class; ?> js-budget">
            <?php
                if(Configure::read('site.currency_symbol_place') == 'left'):
                    $currecncy_place = 'between';
                else:
                    $currecncy_place = 'after';
                endif;  
            ?>  
                <?php
                    echo $this->Form->input('ProjectRange.min_amount', array('label' => __l('Min amount') . ' (' . Configure::read('site.currency') . ')'));
                    echo $this->Form->input('ProjectRange.max_amount', array('label' => __l('Max amount') . ' (' . Configure::read('site.currency') . ')'));
                ?>
            </div>
            <?php echo $this->Form->input('bid_duration', array('label' => __l('Bidding Duration'),'info'  =>  __l('Maximum Bid Duration: ').Configure::read('Project.max_bid_duration') . ' days')); ?>
        </div>
            <div class="input text date-time select required validation:{'message':'Required','allowEmpty':false,'rule':'notempty'}">
                <div class="js-datetime">
                    <div class="js-cake-date">
                                <?php echo $this->Form->input('pickupdate', array('label' => __l('Pick up date'), 'type' => 'date')); ?>
                    </div>
                </div>
            </div>
    </fieldset>
    <fieldset>

    <h3 class="tab-head text-16 textn img-rounded"> <?php echo __l('Vehicle Type');?></h3>
    <div class="input select no-mar js-remove-error-skill required">
        <div class="clearfix skills-block">
            <?php echo $this->Form->input('skill_id',array('multiple' => '', 'options'=>$Skill, 'label' => __l('Vehicle Type'), 'empty' => __l('Please Select'),'class'=>'span10')); ?>
        </div>

    </div>
    <?php if(!empty($error)){?>
            <div class="error-message"><?php echo __l('Required'); ?></div>
        <?php }?>
    </fieldset>
    <fieldset>

    <h3 class="tab-head text-16 textn img-rounded"><?php echo __l('Attachment');?></h3>
    <div class="input file no-mar ver-space">
      <?php    
      echo $this->Form->input('Attachment.filename', array('type' => 'file', 'size' => '33', 'label' => __l('Upload File'), 'class' => "browse-field js-remove-error"));?>
    </div>
    </fieldset>
    <fieldset>
    <?php if(Configure::read('Project.is_enable_project_options')) { ?><legend><?php echo __l('Options');?></legend> <?php } ?>
    <?php   
    $total_fee = $list_fee = Configure::read('project.listing_fee');
    echo $this->Form->input('listing_fee', array('type' => 'hidden', 'id'=> 'js_project_listing_fee',  'value' => $list_fee));
    ?>
    <div class="alert alert-info bot-mspace"><i class="icon-info-sign"></i>
        <?php if(!empty($list_fee)){
            echo __l('Listing Fee'). ' (' . Configure::read('site.currency') . $list_fee . ')';
         } else{
            echo __l('Listing fee is free');
         } ?>
    </div>
    <?php
        if(isPluginEnabled('Projects')){
            if(Configure::read('Project.is_enable_project_options')) {?>
    <div class="input checkbox no-mar">
        <div class="span8 no-mar">



                     <span class="show space">
                     <?php $featured_fee = Configure::read('Project.featured_fee') ?  ' (' . Configure::read('site.currency') . Configure::read('Project.featured_fee') . ')' : '';
                        if(!empty($this->request->data['Project']['is_featured'])){
                        $total_fee += Configure::read('Project.featured_fee');
                        } ?>
                     <?php echo $this->Form->input('is_featured', array('label' => __l('Featured').$featured_fee, 'div'=>false, 'class'=>"js-payment-show {'amount':'".Configure::read('Project.featured_fee')."'}"));?>
                     <span class="info no-mar"><i class="icon-info-sign"></i>Featured projects will be displayed on top.</span>
                     </span>
                     <span class="js-job space">
                        <?php $job_listing_fee = Configure::read('Project.job_listing_fee') ?  ' (' . Configure::read('site.currency') . Configure::read('Project.job_listing_fee') . ')' : '';
                        echo $this->Form->input('is_job_listing', array('label' => __l('Job Listing').$job_listing_fee , 'div'=>false, 'class'=>"js-payment-show js-show {'container':'js-job_listing','amount':'".Configure::read('Project.job_listing_fee')."'}")); ?>
                        <span class="info left-mspace"><i class="icon-info-sign"></i>Displayed as job.</span>
                     </span>


                    <?php
                    $job_listing_class= empty($this->request->data['Project']['is_job_listing']) ? 'hide js-clone' : '';
                    if(!empty($this->request->data['Project']['is_job_listing'])){
                        $total_fee += Configure::read('Project.job_listing_fee');
                    }
                    ?>
                    <div class="<?php echo $job_listing_class; ?> js-job_listing">
                     <span class="show space">
                        <?php
                             echo $this->Form->input('salary_type_id',array('label'=>'Salary type','empty'=>__l('Select')));  
                             echo $this->Form->input('salary',array('label'=>'Salary (' . Configure::read('site.currency') . ')' ));
                             echo $this->Form->input('contact_info');  
                        ?>
                     </span>
                    </div>

                      <span class="show space">
                         <?php $urgent_fee = Configure::read('Project.urgent_fee') ?  ' (' . Configure::read('site.currency') . Configure::read('Project.urgent_fee') . ')' : '';

                        if(!empty($this->request->data['Project']['is_urgent'])){
                            $total_fee += Configure::read('Project.urgent_fee');
                        }

                        echo $this->Form->input('is_urgent', array('label' => __l('Mark Project Urgent').$urgent_fee,  'div'=>false, 'class'=>"js-payment-show {'amount':'".Configure::read('Project.urgent_fee')."'}"));?>
                        <span class="info no-mar"><i class="icon-info-sign"></i>Project will be marked as urgent, and displayed on top(Next to the featured projects).</span>
                        </span>

                            <?php $private_fee = Configure::read('Project.private_project_fee') ?  ' (' . Configure::read('site.currency') . Configure::read('Project.private_project_fee') . ')' : '';
                            //  echo $this->Form->input('is_private', array('label' => __l('Private Project').$private_fee, 'class'=>"js-payment-show js-show {'container':'js-programmer-list','amount':'".Configure::read('Project.private_project_fee')."'}"));

                            $freelancer_class= empty($this->request->data['Project']['is_private']) ? 'hide' : '';
                            ?>
                            <div class="<?php echo $freelancer_class; ?> js-programmer-list">
                                <span class="show space"><?php
                                echo $this->Form->autocomplete('projectuser', array('label' => $this->Html->fAlt(ConstAltVerb::PluralCaps), 'acFieldKey' => 'User.id', 'acMultiple' => true, 'acFields' => array('User.username'), 'acSearchFieldNames' => array('User.username'), 'maxlength' => '255'));?>
                                <span class="info"> <?php echo __l('This is visible only for the selected').' '.$this->Html->fAlt(ConstAltVerb::PluralSmall); ?></span>
                                <?php echo $this->Form->input('type',array('type'=>'hidden','value'=>'freelancers','id'=>'userType'));
                                ?></span>
                            </div>

                        <span class="show space">
                            <div class="js-hidden_bid">
                                <?php
                                    $hidden_bid_fee = Configure::read('Project.hidden_bid_fee') ?  ' (' . Configure::read('site.currency') . Configure::read('Project.hidden_bid_fee') . ')' : '';?>
                                        <?php  echo $this->Form->input('is_hidded_bid', array('label' => __l('Hide My Bids').$hidden_bid_fee,  'div'=>false, 'class'=>"js-payment-show js-bids-hide {'amount':'".Configure::read('Project.hidden_bid_fee')."'}"));
                                    $pre_paid_fee = Configure::read('Project.pre_paid_fee') ?  ' (' . Configure::read('site.currency') . Configure::read('Project.pre_paid_fee') . ')' : '';
                                    //echo $this->Form->input('is_pre_paid', array('label' => __l('Pre Paid Project').$pre_paid_fee, 'class'=>"js-payment-show {'amount':'".Configure::read('Project.pre_paid_fee')."'}"));
                                ?>
                                <span class="info no-mar"><i class="icon-info-sign"></i>Bids on the project will be hide.</span>
                           </div>
                          </span>

       </div>
    </div>
    <?php } } ?>
    <dl class="well bot-mspace space no-shad no-bor clearfix">
      <dt class="pull-left text-14 textb"><?php echo __l('Total Payment');?></dt>
      <dd class="pull-right text-16 textb greenc"><?php if(Configure::read('Project.is_enable_project_options')) { echo Configure::read('site.currency'); } ?><span class="js-total"><?php echo $this->Html->siteCurrencyFormat($this->Html->cCurrency($total_fee)); ?></span></dd>
    </dl>
    </fieldset>
    <?php                
            foreach($gateway_options as $key => $gateway_option){                
                if($key==ConstPaymentGateways::Wallet){
                    $gateway_option=$gateway_option . ' ('.__l('Current Balance ') . Configure::read('site.currency') . $user_available_balance . ')';
                }
                    $gateways[$key]=$gateway_option;                        
            }?>


    <div class="well no-bor no-shad clearfix">
      <div class="submit pull-right no-mar">
        <?php echo $this->Form->submit(__l('Post'), array('id' => 'js-project-add-id',"class"=>"btn space span3 no-mar","div"=>false)); ?>
      </div>
    </div>
<?php echo $this->Form->end();?>
</section>
  </div>
</div>

Upvotes: 1

Views: 1488

Answers (3)

Fazal Rasel
Fazal Rasel

Reputation: 4526

Your validation rules is not coded perfectly. You miss a bracket--

This should be looks like-

Array (
    'pickupdate' => array(
        'rule1' => array(
            'rule' => 'notEmpty',
            'message' => __l('Required11')
        ) ,
        'rule2' => array(
            'rule' => 'date',
            'message' => __l('Must be a valid date')
        )
    )// you miss that..
)

Upvotes: 1

user177913
user177913

Reputation: 475

Full Form Code : add.ctp (VIEW FORM)

<?php /* SVN: $Id: $ */ ?>
<div class="js-validation-part">

  <div class="projects form js-responses">
  <section class="row ver-space ver-smspace">
<?php if (!(isset($this->request->params['prefix']) and $this->request->params['prefix'] ==     'admin')) {?>
      <div class="tab-head bot-mspace text-13 clearfix"><h2 class="pull-left text-16 no-mar"><?php echo $this->Html->eAlt(ConstAltVerb::SingularCaps).' Control Panel';?></h2>
    <?php echo $this->element('employer-menu'); ?>
  </div>
<?php }?>

<h3 class="grayc"><?php echo __l('Post your project');?> </h3>

<?php echo $this->Form->create('Project', array('class' => 'form-horizontal js-upload-form', 'enctype' => 'multipart/form-data'));?>
    <fieldset>
        <h3 class="tab-head text-16 textn img-rounded"><?php echo __l('Type');?></h3>
        <div class="input radio radio-active-style top-mspace left-space">
            <?php  echo $this->Form->input('project_type_id', array('legend' => false,'type' => 'radio','class'=>'js-online','div' =>false));?>
            <div class="ver-space">
                <span class="help-block no-mar"><?php echo __l('Online:').' '.$this->Html->eAlt(ConstAltVerb::SingularCaps).' '.__l('or').' '.$this->Html->fAlt(ConstAltVerb::SingularSmall).' '.__l('can accomplish his/her job completely over net'); ?></span>
                <span class="help-block no-mar"> <?php echo __l('Offline:').' '.$this->Html->eAlt(ConstAltVerb::SingularCaps).' '.__l('or').' '.$this->Html->fAlt(ConstAltVerb::SingularSmall).' '.__l('needs to physically interact with each other'); ?></span>
            </div>
        </div>
    </fieldset>

    <fieldset>
    <?php
            if($this->Auth->user('role_id') == ConstUserTypes::Admin){
                echo $this->Form->input('user_id', array('label' => $this->Html->eAlt(ConstAltVerb::SingularCaps), 'empty' => __l('Please Select')));
            } ?>
        <h3 class="tab-head text-16 textn img-rounded"><?php echo __l('Info');?></h3>
        <div class="input text required ver-space">
          <?php echo $this->Form->input('name', array('label' => __l('Project Name'))); ?>
        </div>
        <div class="input textarea required">
          <?php echo $this->Form->input('description', array('type'=>'textarea','class' => 'js-description-count {"display":"js-description","field":"js-description-count","count":"'.Configure::read('Project.project_max_description_length').'"}','label'=>__l('Description'),'info'=>__l('Do not post any contact info. You can communicate with').' '.$this->Html->fAlt(ConstAltVerb::PluralCaps).' '.__l('on your project message board.').' <span class="character-info">'.__l('You have').' <span id="js-description-count"></span> '.__l('characters left').'</span>'));?>
         </div>
    </fieldset>
    <?php if(isPluginEnabled('ProjectCategory')): ?>
    <fieldset>
    <h3 class="tab-head text-16 textn img-rounded"><?php echo __l('Opportunity Type');?></h3>
    <div class="input select ver-space required validation:{'message':'Required','allowEmpty':false,'rule':'numeric'}">
      <?php echo $this->Form->input('project_category_id',array('multiple' => '','label' =>  __l('Opportunity Type'),'class'=>'span10','empty' => __l('Please Select')));?>

    <?php if(!empty($error)){?>
            <div class="error-message"><?php echo __l('Required'); ?></div>
        <?php } ?>
    </fieldset>
    <?php endif;?>
    <fieldset>

    <h3 class="tab-head text-16 textn img-rounded"><?php echo __l('Location');?></h3>
    <div class="mapblock-info">
        <div class="clearfix address-input-block">
        <?php
            echo $this->Form->input('address', array('type'=>'text','label' => __l('Address'), 'id' => 'ProjectAddress','class'=>'js-offline address-error-message')); ?>
        </div>
        <?php   echo $this->Form->input('latitude', array('id' => 'latitude', 'type' => 'hidden'));
            echo $this->Form->input('longitude', array('id' => 'longitude', 'type' => 'hidden'));
            echo $this->Form->input('country_id',array('class'=>'js-address','id'=>'js-country_id','type' => 'hidden'));
            echo $this->Form->input('State.name', array('type' => 'hidden'));
            echo $this->Form->input('City.name', array('type' => 'hidden'));
        ?>
        <div id="address-info" class="hide"><?php echo __l('Please select correct address value'); ?></div>
        <div id="mapblock">
            <div id="mapframe">
                <div id="mapwindow"></div>
            </div>
        </div>
    </div>
    </fieldset>
    <fieldset>
        <h3 class="tab-head text-16 textn img-rounded"><?php echo __l('Range');?></h3>
        <div class="input select required ver-space">
            <?php
            echo $this->Form->input('project_range_id', array('label' => __l('Project Budget'),'empty' => __l('Please Select')));
            $class='';
            if (empty($this->request->data['Project']['project_range_id']) || (!empty($this->request->data['Project']['project_range_id']) &&       $this->request->data['Project']['project_range_id'] !='custom')):
                $class ='hide';
            endif;
        ?>
        </div>
        <div class="input text required">
            <div class="<?php echo $class; ?> js-budget">
            <?php
                if(Configure::read('site.currency_symbol_place') == 'left'):
                    $currecncy_place = 'between';
                else:
                    $currecncy_place = 'after';
                endif;  
            ?>  
                <?php
                    echo $this->Form->input('ProjectRange.min_amount', array('label' => __l('Min amount') . ' (' . Configure::read('site.currency') . ')'));
                    echo $this->Form->input('ProjectRange.max_amount', array('label' => __l('Max amount') . ' (' . Configure::read('site.currency') . ')'));
                ?>
            </div>
            <?php echo $this->Form->input('bid_duration', array('label' => __l('Bidding Duration'),'info'  =>  __l('Maximum Bid Duration: ').Configure::read('Project.max_bid_duration') . ' days')); ?>
        </div>
            <div class="input text date-time select required validation:{'message':'Required','allowEmpty':false,'rule':'notempty'}">
                <div class="js-datetime">
                    <div class="js-cake-date">
                                <?php echo $this->Form->input('pickupdate', array('label' => __l('Pick up date'), 'type' => 'date')); ?>
                    </div>
                </div>
            </div>
    </fieldset>
    <fieldset>

    <h3 class="tab-head text-16 textn img-rounded"> <?php echo __l('Vehicle Type');?></h3>
    <div class="input select no-mar js-remove-error-skill required">
        <div class="clearfix skills-block">
            <?php echo $this->Form->input('skill_id',array('multiple' => '', 'options'=>$Skill, 'label' => __l('Vehicle Type'), 'empty' => __l('Please Select'),'class'=>'span10')); ?>
        </div>

    </div>
    <?php if(!empty($error)){?>
            <div class="error-message"><?php echo __l('Required'); ?></div>
        <?php }?>
    </fieldset>
    <fieldset>

    <h3 class="tab-head text-16 textn img-rounded"><?php echo __l('Attachment');?></h3>
    <div class="input file no-mar ver-space">
      <?php    
      echo $this->Form->input('Attachment.filename', array('type' => 'file', 'size' => '33', 'label' => __l('Upload File'), 'class' => "browse-field js-remove-error"));?>
    </div>
    </fieldset>
    <fieldset>
    <?php if(Configure::read('Project.is_enable_project_options')) { ?><legend><?php echo __l('Options');?></legend> <?php } ?>
    <?php   
    $total_fee = $list_fee = Configure::read('project.listing_fee');
    echo $this->Form->input('listing_fee', array('type' => 'hidden', 'id'=> 'js_project_listing_fee',  'value' => $list_fee));
    ?>
    <div class="alert alert-info bot-mspace"><i class="icon-info-sign"></i>
        <?php if(!empty($list_fee)){
            echo __l('Listing Fee'). ' (' . Configure::read('site.currency') . $list_fee . ')';
         } else{
            echo __l('Listing fee is free');
         } ?>
    </div>
    <?php
        if(isPluginEnabled('Projects')){
            if(Configure::read('Project.is_enable_project_options')) {?>
    <div class="input checkbox no-mar">
        <div class="span8 no-mar">



                     <span class="show space">
                     <?php $featured_fee = Configure::read('Project.featured_fee') ?  ' (' . Configure::read('site.currency') . Configure::read('Project.featured_fee') . ')' : '';
                        if(!empty($this->request->data['Project']['is_featured'])){
                        $total_fee += Configure::read('Project.featured_fee');
                        } ?>
                     <?php echo $this->Form->input('is_featured', array('label' => __l('Featured').$featured_fee, 'div'=>false, 'class'=>"js-payment-show {'amount':'".Configure::read('Project.featured_fee')."'}"));?>
                     <span class="info no-mar"><i class="icon-info-sign"></i>Featured projects will be displayed on top.</span>
                     </span>
                     <span class="js-job space">
                        <?php $job_listing_fee = Configure::read('Project.job_listing_fee') ?  ' (' . Configure::read('site.currency') . Configure::read('Project.job_listing_fee') . ')' : '';
                        echo $this->Form->input('is_job_listing', array('label' => __l('Job Listing').$job_listing_fee , 'div'=>false, 'class'=>"js-payment-show js-show {'container':'js-job_listing','amount':'".Configure::read('Project.job_listing_fee')."'}")); ?>
                        <span class="info left-mspace"><i class="icon-info-sign"></i>Displayed as job.</span>
                     </span>


                    <?php
                    $job_listing_class= empty($this->request->data['Project']['is_job_listing']) ? 'hide js-clone' : '';
                    if(!empty($this->request->data['Project']['is_job_listing'])){
                        $total_fee += Configure::read('Project.job_listing_fee');
                    }
                    ?>
                    <div class="<?php echo $job_listing_class; ?> js-job_listing">
                     <span class="show space">
                        <?php
                             echo $this->Form->input('salary_type_id',array('label'=>'Salary type','empty'=>__l('Select')));  
                             echo $this->Form->input('salary',array('label'=>'Salary (' . Configure::read('site.currency') . ')' ));
                             echo $this->Form->input('contact_info');  
                        ?>
                     </span>
                    </div>

                      <span class="show space">
                         <?php $urgent_fee = Configure::read('Project.urgent_fee') ?  ' (' . Configure::read('site.currency') . Configure::read('Project.urgent_fee') . ')' : '';

                        if(!empty($this->request->data['Project']['is_urgent'])){
                            $total_fee += Configure::read('Project.urgent_fee');
                        }

                        echo $this->Form->input('is_urgent', array('label' => __l('Mark Project Urgent').$urgent_fee,  'div'=>false, 'class'=>"js-payment-show {'amount':'".Configure::read('Project.urgent_fee')."'}"));?>
                        <span class="info no-mar"><i class="icon-info-sign"></i>Project will be marked as urgent, and displayed on top(Next to the featured projects).</span>
                        </span>

                            <?php $private_fee = Configure::read('Project.private_project_fee') ?  ' (' . Configure::read('site.currency') . Configure::read('Project.private_project_fee') . ')' : '';
                            //  echo $this->Form->input('is_private', array('label' => __l('Private Project').$private_fee, 'class'=>"js-payment-show js-show {'container':'js-programmer-list','amount':'".Configure::read('Project.private_project_fee')."'}"));

                            $freelancer_class= empty($this->request->data['Project']['is_private']) ? 'hide' : '';
                            ?>
                            <div class="<?php echo $freelancer_class; ?> js-programmer-list">
                                <span class="show space"><?php
                                echo $this->Form->autocomplete('projectuser', array('label' => $this->Html->fAlt(ConstAltVerb::PluralCaps), 'acFieldKey' => 'User.id', 'acMultiple' => true, 'acFields' => array('User.username'), 'acSearchFieldNames' => array('User.username'), 'maxlength' => '255'));?>
                                <span class="info"> <?php echo __l('This is visible only for the selected').' '.$this->Html->fAlt(ConstAltVerb::PluralSmall); ?></span>
                                <?php echo $this->Form->input('type',array('type'=>'hidden','value'=>'freelancers','id'=>'userType'));
                                ?></span>
                            </div>

                        <span class="show space">
                            <div class="js-hidden_bid">
                                <?php
                                    $hidden_bid_fee = Configure::read('Project.hidden_bid_fee') ?  ' (' . Configure::read('site.currency') . Configure::read('Project.hidden_bid_fee') . ')' : '';?>
                                        <?php  echo $this->Form->input('is_hidded_bid', array('label' => __l('Hide My Bids').$hidden_bid_fee,  'div'=>false, 'class'=>"js-payment-show js-bids-hide {'amount':'".Configure::read('Project.hidden_bid_fee')."'}"));
                                    $pre_paid_fee = Configure::read('Project.pre_paid_fee') ?  ' (' . Configure::read('site.currency') . Configure::read('Project.pre_paid_fee') . ')' : '';
                                    //echo $this->Form->input('is_pre_paid', array('label' => __l('Pre Paid Project').$pre_paid_fee, 'class'=>"js-payment-show {'amount':'".Configure::read('Project.pre_paid_fee')."'}"));
                                ?>
                                <span class="info no-mar"><i class="icon-info-sign"></i>Bids on the project will be hide.</span>
                           </div>
                          </span>

       </div>
    </div>
    <?php } } ?>
    <dl class="well bot-mspace space no-shad no-bor clearfix">
      <dt class="pull-left text-14 textb"><?php echo __l('Total Payment');?></dt>
      <dd class="pull-right text-16 textb greenc"><?php if(Configure::read('Project.is_enable_project_options')) { echo Configure::read('site.currency'); } ?><span class="js-total"><?php echo $this->Html->siteCurrencyFormat($this->Html->cCurrency($total_fee)); ?></span></dd>
    </dl>
    </fieldset>
    <?php                
            foreach($gateway_options as $key => $gateway_option){                
                if($key==ConstPaymentGateways::Wallet){
                    $gateway_option=$gateway_option . ' ('.__l('Current Balance ') . Configure::read('site.currency') . $user_available_balance . ')';
                }
                    $gateways[$key]=$gateway_option;                        
            }?>


    <div class="well no-bor no-shad clearfix">
      <div class="submit pull-right no-mar">
        <?php echo $this->Form->submit(__l('Post'), array('id' => 'js-project-add-id',"class"=>"btn space span3 no-mar","div"=>false)); ?>
      </div>
    </div>
<?php echo $this->Form->end();?>
</section>
  </div>
</div>

Upvotes: 0

tremendusapps
tremendusapps

Reputation: 108

Two things here. 1. Be sure you are opening your form in the view or element ctp file with

<?php echo $this->Form->create('Project'); ?>
  1. If your datepicker is a javascript driven datepicker, it might be interfering with your field or field name in some way. After the page has rendered, look at the source and see what happened to your original field. If by 'datepicker' you mean the default HTML selects that cake generates, then it should all be working, considering the above.

  2. You might also check that you are closing your form properly with $this->Form->end(), I had missed this once and the form didn't post right.

Upvotes: 2

Related Questions