Automatically line break in Yii - php

If not including PHP, there is no error.
If include Yii CMenu, automatically added white space before CMenu
Example:
<div id="umenu">
<?php $this->widget('zii.widgets.CMenu', array(
'encodeLabel' => false,
'items' => array(
array('label' => ' ', 'url' => '/', 'itemOptions' => array('class' => 'umenu1')),
array('label' => 'RÓLUNK', 'url' => StaticpageModule::getUrl(1), 'itemOptions' => array('class' => 'umenu2')),
array('label' => 'TERMELÉS', 'url' => StaticpageModule::getUrl(2), 'itemOptions' => array('class' => 'umenu3')),
array('label' => 'A KÁVÉ', 'url' => StaticpageModule::getUrl(3), 'itemOptions' => array('class' => 'umenu4')),
array('label' => 'EGYÜTTMŰKÖDÉS', 'url' => StaticpageModule::getUrl(5), 'itemOptions' => array('class' => 'umenu5')),
array('label' => 'KAPCSOLAT', 'url' => StaticpageModule::getUrl(4), 'itemOptions' => array('class' => 'umenu6')),
),
)); ?>
</div>
Output:

Well, as PeterM said in its comment, you have whitespaces after opening div#menu...
And about double quotes you see in chrome dev tool :
when a string literal is not on the same line with its surrounding tag
then the string literal is displayed on a new line with quotes around
the string literal to make it visible where the string starts and
ends.
What is the purpose of the quotes around some dollar values on certain retail sites?

Change
<div id="umenu">
<?php $this->widget('zii.widgets.CMenu', array(
To
<div id="umenu"><?php $this->widget('zii.widgets.CMenu', array(

From the reference documentation for the widget constructor, it looks like you might need to pass false as the $captureOutput flag to tell it not to push any output to the page.
Try:
<?php $this->widget('zii.widgets.CMenu', array(
'encodeLabel' => false,
'items' => array(
array('label' => ' ', 'url' => '/', 'itemOptions' => array('class' => 'umenu1')),
array('label' => 'RÓLUNK', 'url' => StaticpageModule::getUrl(1), 'itemOptions' => array('class' => 'umenu2')),
array('label' => 'TERMELÉS', 'url' => StaticpageModule::getUrl(2), 'itemOptions' => array('class' => 'umenu3')),
array('label' => 'A KÁVÉ', 'url' => StaticpageModule::getUrl(3), 'itemOptions' => array('class' => 'umenu4')),
array('label' => 'EGYÜTTMŰKÖDÉS', 'url' => StaticpageModule::getUrl(5), 'itemOptions' => array('class' => 'umenu5')),
array('label' => 'KAPCSOLAT', 'url' => StaticpageModule::getUrl(4), 'itemOptions' => array('class' => 'umenu6')),
),
false
));

Related

How to remove controller name in CakePHP Form

My code:
echo $this->Form->create('Usps', array(
'inputDefaults' => array(
'label' => false,
'div' => false
),
'id' => 'form-validate',
'class' => 'form-horizontal',
'novalidate' => 'novalidate',
'url' => array('controller'=>'frondends','action' => 'tariffplan')
));
This produces www.example.com/frontends/tariffplan
I want to see : www.example.com/tariffplan
I changed url as follows:
'url' => array('action' => 'tariffplan')
but this produces :
www.example.com/usps/tariffplan
I searched google but no luck. Any help will be appreciated
Try this:
'url' => array('controller' => '/', 'action' => 'tariffplan')

cakephp-upload won´t validate

I´am using the plugin
https://github.com/josegonzalez/cakephp-upload
for image upload.
I won´t to disable adding post without uploaded image.
How to write validation to it?
class BlogContent extends AppModel
{
public $validate = array(
'title' => array(
'rule' => 'notEmpty',
'message' => 'Titulok musí byť zadaný'
),
'text' => array(
'rule' => 'notEmpty',
'required' => true,
'message' => 'Text musí byť zadaný'
),
'photo' => array(
'isUpload' => array(
'rule' => 'isFileUpload',
'required' => true,
'message' => 'Článok musí obsahovať obrázok',
'last' => false
),
'isCompletedUpload' => array(
'rule' => 'isCompletedUpload',
'message' => 'Obrázok nebol úspešne nahratý',
'last' => false
),
'tempDirExists' => array(
'rule' => 'tempDirExists',
'message' => 'Priečinok TEMP nie je dostupný',
'last' => false
),
...
If I use required=> true for isUpload, it will never validates. However if I not type it, it will validates without uploading image.
View code: admin_add.ctp
<div class="blogContents form">
<?php echo $this->Form->create('BlogContent', array('type' => 'file'));
echo $this->Form->input('title', array('label' => 'Titulok'));
echo $this->Form->input('text', array('class' => 'ckeditor', 'label' => ''));
echo $this->Form->input('image', array('label' => '', 'type' => 'file', 'accept' => 'image/*'));
echo $this->Html->link(__('Vybrať obrázok'), '#', array('class' => 'btn btn-default', 'id' => 'upload'));
echo _('<p>Zvolený obrázok:</p>');
echo $this->Html->div('filelist', '<p>Žiaden obrázok nebol zvolený</p>');
echo $this->Form->input('image_dir', array('type' => 'hidden'));
echo $this->Form->input('active', array('label' => 'Publikované'));
echo $this->Form->submit(__('Uložiť článok'), array('class' => 'btn btn-success')) ?>
</div>

CakePHP input stopped working

I'm completely new with cake, so I have no clue what happened.
this code works :
echo $this->Form->input('phone',
array(
'required' => false,
'div' => 'form-group',
'class' => 'form-control',
'label' => array(
'class' => 'control-label',
'text' => __d('admin', 'Tel. numeris')
),
'placeholder' => __d('admin', 'Tel. numeris'),
'error' => array(
'attributes' => array(
'class' => 'alert alert-danger'
)
)
)
);
this one doesn't :
echo $this->Form->input('email',
array(
'required' => false,
'div' => 'form-group',
'class' => 'form-control',
'label' => array(
'class' => 'control-label',
'text' => __d('admin', 'El.paštas')
),
'placeholder' => __d('admin', 'El.paštas'),
'error' => array(
'attributes' => array(
'class' => 'alert alert-danger'
)
)
)
);
and for example if I change email to, lets say, emailas, it works too(but then it doesnt do anything) :
echo $this->Form->input('emailas',
array(
'required' => false,
'div' => 'form-group',
'class' => 'form-control',
'label' => array(
'class' => 'control-label',
'text' => __d('admin', 'El.paštas')
),
'placeholder' => __d('admin', 'El.paštas'),
'error' => array(
'attributes' => array(
'class' => 'alert alert-danger'
)
)
)
);
could someone please help me or at least tell me where to look? The input stopped working out of the blue, so maybe theres a possibility to somehow restart whole plugin? THANK YOU IN ADVANCE
P.S.
This is how the input field looks atm vs how it should look like : http://imgur.com/bBrkgxM
Try this:
echo $this->Form->input('email',
array(
'required' => false,
'div' => 'form-group',
'class' => 'form-control',
'type' => 'email',
'label' => array(
'class' => 'control-label',
'text' => __d('admin', 'El.paštas')
),
'placeholder' => __d('admin', 'El.paštas'),
'error' => array(
'attributes' => array(
'class' => 'alert alert-danger'
)
)
)
);
And make sure you have email field in database and nowhere is overriding email field (in controller / model)

Cakephp trying to validate non existing input

I have never seen this before. I have a form with multiple models connected to one. When I submit the form, Cake is trying to validate fields with no vaildation and it even is trying to validate a field that I changed the name on. I have cleared the model cache in the tmp folder. I am stumped. Here is my code.
View:
echo $this->Form->create('Lead', array('class' => 'form form-vertical'));
echo $this->Form->input('Lead.project_name', array('class' => 'form-control', 'div'=>array('class'=>'col-md-12'), 'value' => 'Project'.$userId));
echo $this->Form->input('Lead.sales_owner', array('class' => 'form-control', 'value' => $fullName, 'div'=>array('class'=>'col-md-4')));
$leadSourceOptions = array('Door to Door' => 'Door to Door','Referral' => 'Referral','Inbound Call' => 'Inbound Call','Self Generated by Closer' => 'Self Generated by Closer','Tradeshows' => 'Tradeshows','Telemarketing' => 'Telemarketing',);
echo $this->Form->input('Lead.lead_source', array('class' => 'form-control', 'type' => 'select', 'options' => $leadSourceOptions, 'div'=>array('class'=>'col-md-4')));
$typeOptions = array('Individual' => 'Individual', 'Business' => 'Business', 'Government' => 'Government');
echo $this->Form->input('Lead.type', array('class' => 'form-control', 'type' => 'select', 'options' => $typeOptions, 'div'=>array('class'=>'col-md-6')));
$taxOptions = array('Individual' => 'Individual', 'Corporation' => 'Corporation', 'LLC (Corporation)' => 'LLC (Corporation)', 'LLC (Non-Corporation)' => 'LLC (Non-Corporation)', 'Partnership' => 'Partnership', 'Sole Proprietor' => 'Sole Proprietor', 'Tax Exempt' => 'Tax Exempt');
echo $this->Form->input('Lead.tax_entity', array('class' => 'form-control', 'type' => 'select', 'options' => $taxOptions, 'div'=>array('class'=>'col-md-6')));
echo $this->Form->input('Customer.first_name', array('class' => 'form-control', 'div'=>array('class'=>'col-md-5')));
echo $this->Form->input('Customer.last_name', array('class' => 'form-control', 'div'=>array('class'=>'col-md-5')));
$titleOptions = array('Mr' => 'Mr', 'Mrs' => 'Mrs', 'Ms' => 'Ms');
echo $this->Form->input('Customer.title', array('class' => 'form-control', 'type' => 'select', 'options' => $titleOptions, 'div'=>array('class'=>'col-md-2')));
echo $this->Form->input('Customer.email', array('class' => 'form-control', 'div'=>array('class'=>'col-md-5')));
echo $this->Form->input('Customer.phone', array('class' => 'form-control', 'placeholder' => '123-456-7890', 'div'=>array('class'=>'col-md-5')));
echo $this->Form->input('Customer.phone_extension', array('required' => false, 'class' => 'form-control', 'label' => 'Ext', 'div'=>array('class'=>'col-md-2')));
$phoneOptions = array('Home' => 'Home', 'Mobile' => 'Mobile', 'Business' => 'Business', 'Business Fax' => 'Business Fax', 'Home Fax' => 'Home Fax', 'Pager' => 'Pager', 'Skype' => 'Skype');
echo $this->Form->input('Customer.phone_type', array('class' => 'form-control', 'type' => 'select', 'options' => $phoneOptions, 'div'=>array('class'=>'col-md-6')));
echo $this->Form->input('Customer.best_time_of_day_to_reach', array('class' => 'form-control', 'div'=>array('class'=>'col-md-6')));
echo $this->Form->input('Customer.address', array('class' => 'form-control', 'div'=>array('class'=>'col-md-6')));
echo $this->Form->input('Customer.address_line_2', array('class' => 'form-control', 'div'=>array('class'=>'col-md-6')));
echo $this->Form->input('Customer.city', array('class' => 'form-control', 'div'=>array('class'=>'col-md-5')));
echo $this->Form->input('Customer.state', array('class' => 'form-control', 'type' => 'select', 'options' => $states, 'selected' => 'UT', 'div'=>array('class'=>'col-md-5')));
echo $this->Form->input('Customer.zip', array('class' => 'form-control', 'div'=>array('class'=>'col-md-2')));
echo '<div class="clear"></div>';
echo $this->Form->input('mailing', array('type' => 'checkbox', 'label' => 'Mailing address the is different from the home address?', 'hiddenField' => false, 'div'=>array('class'=>'col-md-12')));
echo $this->Form->input('Customer.mailing_street', array('class' => 'form-control', 'div'=>array('class'=>'col-md-6')));
echo $this->Form->input('Customer.mailing_address_line_2', array('class' => 'form-control', 'div'=>array('class'=>'col-md-6')));
echo $this->Form->input('Customer.mailing_city', array('class' => 'form-control', 'div'=>array('class'=>'col-md-5')));
echo $this->Form->input('Customer.mailing_state', array('class' => 'form-control', 'type' => 'select', 'options' => $states, 'selected' => '', 'div'=>array('class'=>'col-md-5')));
echo $this->Form->input('Customer.mailing_zip', array('class' => 'form-control', 'div'=>array('class'=>'col-md-2')));
$serviceTypeOptions = array('Residential' => 'Residential', 'Commercial' => 'Commercial');
echo $this->Form->input('EnergyUsage.service_type', array('class' => 'form-control', 'type' => 'select', 'options' => $serviceTypeOptions, 'div'=>array('class'=>'col-md-4')));
echo $this->Form->input('EnergyUsage.utility', array('class' => 'form-control', 'type' => 'select', 'options' => $utilities, 'selected' => 'Rocky Mountain Power (Utah Power)', 'div'=>array('class'=>'col-md-4')));
$voltageOptions = array('240 V : 120 V Split Phase' => '240 V : 120 V Split Phase', 'V Delta: 277 V Wye 3 Phase' => 'V Delta: 277 V Wye 3 Phase', '208 V Delta 3 Phase' => '240 V Split Phase Delta 3 Phase (Aka Stinger, Or High Leg Delta)', '240 V Split Phase Delta 3 Phase (Aka Stinger, Or High Leg Delta)' => '208 V Delta : 120 V Wye 3 Phase', '208 V Delta : 120 V Wye 3 Phase' => '240 V Delta 3 Phase', '240 V Delta 3 Phase');
echo $this->Form->input('EnergyUsage.service_config_voltage', array('class' => 'form-control', 'type' => 'select', 'options' => $voltageOptions, 'div'=>array('class'=>'col-md-4')));
echo $this->Form->input('EnergyUsage.utility_account_number', array('class' => 'form-control', 'div'=>array('class'=>'col-md-6')));
echo $this->Form->input('EnergyUsage.billing_period_one_start_date', array('class' => 'form-control datepicker', 'div'=>array('class'=>'col-md-6')));
echo $this->Form->input('EnergyUsage.notes', array('class' => 'form-control', 'div'=>array('class'=>'col-md-12')));
function daysInMonth($month){
$today = date('Y-m-d');
$date = explode('-',$today);
if($month > $date[1]){ $year = $date[0]-1;}else{$year = date('Y');}
return cal_days_in_month(CAL_GREGORIAN, $month, $year);
}
echo $this->Form->input('MonthyUsage.jan_billing_days', array('class' => 'form-control', 'value' => daysInMonth(1), 'div'=>array('class'=>'col-md-6 col-sm-6')));
echo $this->Form->input('MonthyUsage.jan_consumption', array('class' => 'form-control', 'div'=>array('class'=>'col-md-6 col-sm-6')));
echo $this->Form->input('MonthyUsage.feb_billing_days', array('class' => 'form-control', 'value' => daysInMonth(2), 'div'=>array('class'=>'col-md-6 col-sm-6')));
echo $this->Form->input('MonthyUsage.feb_consumption', array('class' => 'form-control', 'div'=>array('class'=>'col-md-6 col-sm-6')));
echo $this->Form->input('MonthyUsage.mar_billing_days', array('class' => 'form-control', 'value' => daysInMonth(3), 'div'=>array('class'=>'col-md-6 col-sm-6')));
echo $this->Form->input('MonthyUsage.mar_consumption', array('class' => 'form-control', 'div'=>array('class'=>'col-md-6 col-sm-6')));
echo $this->Form->input('MonthyUsage.apr_billing_days', array('class' => 'form-control', 'value' => daysInMonth(4), 'div'=>array('class'=>'col-md-6 col-sm-6')));
echo $this->Form->input('MonthyUsage.apr_consumption', array('class' => 'form-control', 'div'=>array('class'=>'col-md-6 col-sm-6')));
echo $this->Form->input('MonthyUsage.may_billing_days', array('class' => 'form-control', 'value' => daysInMonth(5), 'div'=>array('class'=>'col-md-6 col-sm-6')));
echo $this->Form->input('MonthyUsage.may_consumption', array('class' => 'form-control', 'div'=>array('class'=>'col-md-6 col-sm-6')));
echo $this->Form->input('MonthyUsage.jun_billing_days', array('class' => 'form-control', 'value' => daysInMonth(6), 'div'=>array('class'=>'col-md-6 col-sm-6')));
echo $this->Form->input('MonthyUsage.jun_consumption', array('class' => 'form-control', 'div'=>array('class'=>'col-md-6 col-sm-6')));
echo $this->Form->input('MonthyUsage.jul_billing_days', array('class' => 'form-control', 'value' => daysInMonth(7), 'div'=>array('class'=>'col-md-6 col-sm-6')));
echo $this->Form->input('MonthyUsage.jul_consumption', array('class' => 'form-control', 'div'=>array('class'=>'col-md-6 col-sm-6')));
echo $this->Form->input('MonthyUsage.aug_billing_days', array('class' => 'form-control', 'value' => daysInMonth(8), 'div'=>array('class'=>'col-md-6 col-sm-6')));
echo $this->Form->input('MonthyUsage.aug_consumption', array('class' => 'form-control', 'div'=>array('class'=>'col-md-6 col-sm-6')));
echo $this->Form->input('MonthyUsage.sep_billing_days', array('class' => 'form-control', 'value' => daysInMonth(9), 'div'=>array('class'=>'col-md-6 col-sm-6')));
echo $this->Form->input('MonthyUsage.sep_consumption', array('class' => 'form-control', 'div'=>array('class'=>'col-md-6 col-sm-6')));
echo $this->Form->input('MonthyUsage.oct_billing_days', array('class' => 'form-control', 'value' => daysInMonth(10), 'div'=>array('class'=>'col-md-6 col-sm-6')));
echo $this->Form->input('MonthyUsage.oct_consumption', array('class' => 'form-control', 'div'=>array('class'=>'col-md-6 col-sm-6')));
echo $this->Form->input('MonthyUsage.nov_billing_days', array('class' => 'form-control', 'value' => daysInMonth(11), 'div'=>array('class'=>'col-md-6 col-sm-6')));
echo $this->Form->input('MonthyUsage.nov_consumption', array('class' => 'form-control', 'div'=>array('class'=>'col-md-6 col-sm-6')));
echo $this->Form->input('MonthyUsage.dec_billing_days', array('class' => 'form-control', 'value' => daysInMonth(12), 'div'=>array('class'=>'col-md-6 col-sm-6')));
echo $this->Form->input('MonthyUsage.dec_consumption', array('class' => 'form-control', 'div'=>array('class'=>'col-md-6 col-sm-6')));
echo '<div class="col-md-6 margin-top3"></div>';
echo $this->Form->input('EnergyUsage.average_billing_amount', array('class' => 'form-control', 'div'=>array('class'=>'col-md-6')));
//echo $this->Form->input('image_upload', array('class' => 'form-control', 'div'=>array('class'=>'col-md-6'), 'type' => 'file', 'accept' => 'image/*', 'catpture' => 'camera'));
echo $this->Form->end(__('Submit')); ?>
Model:
App::uses('AppModel', 'Model');
class Lead extends AppModel {
public $validate = array('project_name' => array( 'notEmpty' => array('rule' => array('notEmpty'),//'message' => 'Your custom message here',),),);
public $belongsTo = array('User' => array('className' => 'User','foreignKey' => 'user_id','conditions' => '','fields' => '', 'order' => ''));
public $hasMany = array(
'Customer' => array('className' => 'Customer','foreignKey' => 'lead_id','dependent' => false,),
'EngeryUsage' => array('className' => 'EngeryUsage','foreignKey' => 'lead_id','dependent' => false, ),
'MonthlyUsage' => array('className' => 'MonthlyUsage', 'foreignKey' => 'lead_id','dependent' => false,),);
}
App::uses('AppModel', 'Model');
class Customer extends AppModel {
public $validate = array(
'lead_id' => array('numeric' => array('rule' => array('numeric'),//'message' => 'Your custom message here', ),),
'first_name' => array('notEmpty' => array('rule' => array('notEmpty'),//'message' => 'Your custom message here', ),),
'last_name' => array('notEmpty' => array('rule' => array('notEmpty'), //'message' => 'Your custom message here',), ),
'phone' => array('notEmpty' => array('rule' => array('notEmpty'),//'message' => 'Your custom message here',),),
'phone_extension' => array('numeric' => array('rule' => array('numeric'), 'message' => 'Your custom message here','allowEmpty' => true,'required' => false,),),
'address' => array('notEmpty' => array('rule' => array('notEmpty'),//'message' => 'Your custom message here',),),
'city' => array('notEmpty' => array('rule' => array('notEmpty'),//'message' => 'Your custom message here',),),
'state' => array('notEmpty' => array('rule' => array('notEmpty'),//'message' => 'Your custom message here',),),
'zip' => array('numeric' => array('rule' => array('numeric'),//'message' => 'Your custom message here',),),
);
public $belongsTo = array('Lead' => array('className' => 'Lead','foreignKey' => 'lead_id',));
}
App::uses('AppModel', 'Model');
class EnergyUsage extends AppModel {
public $validate = array('lead_id' => array('numeric' => array('rule' => array('numeric'),//'message' => 'Your custom message here',),),);
public $belongsTo = array('Lead' => array('className' => 'Lead','foreignKey' => 'lead_id'));
}
App::uses('AppModel', 'Model');
class MonthyUsage extends AppModel {
public $belongsTo = array( 'Lead' => array('className' => 'Lead','foreignKey' => 'lead_id'));
}
in the controller when I debug validationErrors I get:
array(
'phone_extension' => array(),
'best_time_of_day_to_reach' => array(),
'address_line_2' => array(),
'mailing_street' => array(),
'mailing_address_line_2' => array(),
'mailing_city' => array(),
'mailing_zip' => array(),
'ext' => array()
)
This is the debug statement with the customer input fields removed:
array(
'Lead' => array(
'project_name' => 'Project1',
'sales_owner' => 'Nate Branning',
'lead_source' => 'Door to Door',
'type' => 'Individual',
'tax_entity' => 'Individual'
),
'Customer' => array(
'first_name' => '',
'last_name' => '',
'title' => 'Mr',
'email' => '',
'phone' => '',
'phone_extension' => '',
'phone_type' => 'Home',
'best_time_of_day_to_reach' => '',
'address' => '',
'address_line_2' => '',
'city' => '',
'state' => 'UT',
'zip' => '',
'mailing_street' => '',
'mailing_address_line_2' => '',
'mailing_city' => '',
'mailing_state' => 'AL',
'mailing_zip' => ''
),
'EnergyUsage' => array(
'service_type' => 'Residential',
'utility' => 'Rocky Mountain Power (Utah Power)',
'service_config_voltage' => '240 V : 120 V Split Phase',
'utility_account_number' => '',
'billing_period_one_start_date' => '',
'notes' => '',
'average_billing_amount' => ''
),
'MonthyUsage' => array(
'jan_billing_days' => '31',
'jan_consumption' => '',
'feb_billing_days' => '28',
'feb_consumption' => '',
'mar_billing_days' => '31',
'mar_consumption' => '',
'apr_billing_days' => '30',
'apr_consumption' => '',
'may_billing_days' => '31',
'may_consumption' => '',
'jun_billing_days' => '30',
'jun_consumption' => '',
'jul_billing_days' => '31',
'jul_consumption' => '',
'aug_billing_days' => '31',
'aug_consumption' => '',
'sep_billing_days' => '30',
'sep_consumption' => '',
'oct_billing_days' => '31',
'oct_consumption' => '',
'nov_billing_days' => '30',
'nov_consumption' => '',
'dec_billing_days' => '31',
'dec_consumption' => ''
)
)
Thanks in advance.
I solved my problem. I had the associations wrong. Customer, EnergyUsage and MonthyUsage belong to Lead. Where the error was in the leads controller I had the association as hasMany. Whe I changed it to hasOne it fixed the issue. I think cake was trying to validate Customer more than once.

How to merge two arrays into one in CodeIgniter?

This is my config file which contains form attributes in CodeIgniter.
$config['reg_attribute'] = array(
'form' => array(
'id' => 'reg-form',
'class' => 'form-horizontal',
'role' => 'form'
),
'name' => array(
'id'=>'reg-name',
'class' => 'form-control',
'name'=>'name',
'placeholder' => 'Enter name',
'value'=>set_value('name')
),
'gender' => array(
'id'=>'reg-reg',
'class' => 'form-control',
'name'=>'gender',
'value'=>set_value('gender')
),
'contact_no' => array(
'id'=>'reg-reg',
'class' => 'form-control',
'name'=>'contact_no',
'placeholder' => 'Enter Phone number',
'value'=>set_value('contact_no')
),
'email'=> array(
'id'=>'reg-email',
'class' => 'form-control',
'name'=>'email',
'placeholder' => 'Enter Email',
'value'=>set_value('email')
),
'password' =>array(
'id'=>'reg-password',
'class' => 'form-control',
'name'=>'password',
'placeholder'=>'Enter Password',
'value'=>set_value('password')
),
'confirm_password' =>array(
'id'=>'reg-password',
'class' => 'form-control',
'name'=>'confirm_password',
'placeholder'=>'Enter Confirm Password',
'value'=>set_value('confirm_password')
),
'submit' =>array(
'id' => 'btn-login',
'class' => 'btn btn-success',
'name' => 'submit',
'value' => 'Register'
)
);
Here I'm loading the form attributes from config and storing it into
an array $data["reg_attrib"]
$this->config->load('reg_rules');
$data["reg_attrib"] = $this->config->item("reg_attribute");
I have an another array which is $add_form
$add_form = array(
'action' => base_url('admin/user/insert'),
'title' => 'Add User',
);
Now I want to merge both the array's into a single array
and send it to view i.e to $add_attributes.
$this->admin_layout->view('admin/add_user',$add_attributes);
Simply merge them with array_merge(). Try this -
$add_attributes = array_merge($data["reg_attrib"], $add_form);
use array_merge() function like
$merged_arr = array_merge($arr1,$arr2);
in your case it will be same as #BOSE suggested:
$add_attributes = array_merge($data["reg_attrib"], $add_form);

Categories