I have 2 forms, the save message is displayed for 1st, but don't display on another.
1st view give confirmation message but the 2nd don't, the data is saved in tables.
gist for codes
in the above gist, you can see the controller and views for both.
You can used this code for you solution. Check set Message code in below.
view.php
<div class="ibox">
<div class="ibox-heading">
<div class="ibox-title">
<h3><?PHP echo(($model->isNewRecord) ? 'Create Fee Structure' : 'Update Fee Structure'); ?></h3>
</div>
</div>
<!-- /.box-header -->
<!-- Set Message start -->
<?php if(Yii::app()->user->hasFlash('confirm')):?>
<div class="info">
<?php echo Yii::app()->user->getFlash('confirm'); ?>
</div>
<?php endif; ?>
<!-- Message end -->
<!-- form start -->
<?php
$form = $this->beginWidget('CActiveForm', array(
'id' => 'fee_structure_form',
'enableAjaxValidation' => true,
'htmlOptions' => array(
'enctype' => 'multipart/form-data',
'role' => 'form'
),
'clientOptions' => array(
'validateOnSubmit' => true,
'validateOnChange' => true,
'validateOnType' => false,
),
)); ?>
<div class="ibox-content">
<div class="row">
<div class="col-md-6 col-xs-12">
<div class="form-group">
<?PHP
echo $form->label($model, 'class_id');
echo $form->dropDownList($model, 'class_id', $studentClasses,array('placeholder' => 'Class', 'class' => 'form-control'));
echo $form->error($model,'class_id');
?>
</div>
<div class="form-group">
<?PHP
echo $form->label($model, 'fee_type');
echo $form->dropDownList($model, 'fee_type', $feeTypes, array('placeholder' => 'Fee Type', 'class' => 'form-control'));
echo $form->error($model,'fee_type');
?>
</div>
<div class="form-group">
<?PHP
echo $form->label($model, 'amount');
echo $form->textField($model, 'amount', array('placeholder' => 'Amount', 'class' => 'form-control'));
echo $form->error($model,'amount');
?>
</div>
<div class="form-group">
<?PHP
echo $form->label($model, 'remarks');
echo $form->textField($model, 'remarks', array('placeholder' => 'Remarks', 'class' => 'form-control'));
echo $form->error($model,'remarks');
?>
</div>
</div>
</div>
</div>
<div class="ibox-footer col-md-12 col-xs-12" style="margin-bottom: 60px;">
<button class="btn col-md-3 col-xs-12 btn-primary pull-left" type="submit">
<?PHP echo Definations::SAVEFORM; ?>
</button>
</div>
<?PHP
$this->endWidget();
?>
</div>
Related
I'm trying to create a dynamic form for one of my projects. I used wbraganca's Dynamic From to achieve this. In my dynamic form I have a DepDrop to show subcategories list from a parent category.
My _form.php
<?php $form = ActiveForm::begin(['id' => 'dynamic-form']); ?>
<div class="row">
<div class="col-md-6">
<?= $form->field($model, 'rq_job_no')->textInput() ?>
</div>
<div class="col-md-6">
<?= $form->field($model, 'rq_req_date')->widget(\yii\jui\DatePicker::class, [
//'language' => 'ru',
'dateFormat' => 'php:Y-m-d',
'clientOptions' => [
'changeMonth' => true,
'changeYear' => true,
'showButtonPanel' => true,
'yearRange' => '1990:2030',
'minDate' => date('Y-m-d'),
],
'options' => ['class' => 'form-control', 'readOnly' => true, 'placeholder' => 'Enter the Item Required Date'],
]) ?>
</div>
<div class="col-md-6">
<?= $form->field($model, 'rq_priority_type')->dropDownList(['urgent' => 'Urgent', 'normal' => 'Normal'], ['prompt' => '--Select Priority Type--']) ?>
</div>
<div class="col-md-6">
</div>
<div class="col-md-6">
<?= $form->field($model, 'rq_approval_type')->dropDownList([1 => ' Approved Vendor Needed', 2 => 'Approved Submitted Needed', 3 => 'Warranty Certificate to be Collected', 4 => 'Long Lead Material',], ['prompt' => '--Select Type of Approval--']) ?>
<?php echo $form->field($model, 'rq_cat_type')->widget(Select2::class, [
'data' => $catData,
'options' => ['placeholder' => '--Select Request Type--', 'class' => 'form-control'],
'pluginOptions' => [
'allowClear' => true
],
]);
?>
</div>
<div class="col-md-12">
<?= $form->field($model, 'rq_remarks')->textarea(['rows' => 6]) ?>
</div>
</div>
<!-- code for dynamic form -->
<div class="panel panel-default">
<div class="panel-heading">
<h4><i class="glyphicon glyphicon-envelope"></i> Request Items</h4>
</div>
<div class="panel-body">
<?php DynamicFormWidget::begin([
'widgetContainer' => 'dynamicform_wrapper', // required: only alphanumeric characters plus "_" [A-Za-z0-9_]
'widgetBody' => '.container-items', // required: css class selector
'widgetItem' => '.item', // required: css class
'limit' => 10, // the maximum times, an element can be cloned (default 999)
'min' => 1, // 0 or 1 (default 1)
'insertButton' => '.add-item', // css class
'deleteButton' => '.remove-item', // css class
'model' => $modelsAddress[0],
'formId' => 'dynamic-form',
'formFields' => [
'item_name',
'item_qty',
'item_unit',
],
]); ?>
<div class="container-items">
<!-- widgetContainer -->
<?php foreach ($modelsAddress as $i => $modelAddress) : ?>
<div class="item panel panel-default">
<!-- widgetBody -->
<div class="panel-heading">
<h4 class="panel-title pull-left">Items</h4>
<div class="pull-right">
<button type="button" class="add-item btn btn-success btn-xs"><i class="fa fa-plus"></i></button>
<button type="button" class="remove-item btn btn-danger btn-xs"><i class="fa fa-minus"></i></button>
</div>
<div class="clearfix"></div>
</div>
<div class="panel-body">
<?php
// necessary for update action.
if (!$modelAddress->isNewRecord) {
echo Html::activeHiddenInput($modelAddress, "[{$i}]rt_id");
}
?>
<?php //$form->field($modelAddress, "[{$i}]rt_item")->textInput(['maxlength' => true]) ?>
<?= $form->field($modelAddress, "[{$i}]rt_item")->widget(DepDrop::class, [
'options' => ['id' => 'reqitems-'.$i.'-rt_item'],
'pluginOptions' => [
'depends' => ['requests-rq_cat_type'],
'placeholder' => '--Select Location--',
'url' => Url::to(['/requests/subcat'])
]
]); ?>
<div class="row">
<div class="col-sm-6">
<?= $form->field($modelAddress, "[{$i}]rt_qty")->textInput(['maxlength' => true]) ?>
</div>
<div class="col-sm-6">
<?= $form->field($modelAddress, "[{$i}]rt_unit")->textInput(['maxlength' => true]) ?>
</div>
</div><!-- .row -->
</div>
</div>
<?php endforeach; ?>
</div>
<?php DynamicFormWidget::end(); ?>
</div>
</div>
<div class="form-group">
<?= Html::submitButton('Save', ['class' => 'btn btn-success']) ?>
</div>
<?php ActiveForm::end(); ?>
My Controller action to load the subcategory
public function actionSubcat()
{
Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
$out = [];
if (isset($_POST['depdrop_parents'])) {
$parents = $_POST['depdrop_parents'];
if ($parents != null) {
$cat_id = $parents[0];
$out = self::getSubCatList($cat_id);
return ['output' => $out, 'selected' => ''];
}
}
return ['output' => 'No Category Available', 'selected' => ''];
}
public function getSubCatList($cat_id)
{
$output = [];
$category = Item::find()->where(['item_category' => $cat_id])->orderBy('item_title')->all();
if (empty($category)) {
$output[] = ['id' => '0', 'name' => 'No Category Available'];
} else {
foreach ($category as $cat) {
$output[] = ['id' => $cat->item_id, 'name' => $cat->item_title];
}
}
return $output;
}
My problem is that DepDrop is only loading the subcategory for the first loop of the dynamic form and leaves the rest loop blank. Attached screenshot for your reference.
Can anyone help by pointing what I am missing or how can I achieve my requirement.
Anyone pls help ...
This is my Controller code (Actions.php)
public function add_admin()
{
$data['employee'] = $this->employee_model->get_new();
$data['department'] = $this->employee_model->dpdown_admins();
$data['gender'] = $this->employee_model->dpdown_gender();
$data['status'] = $this->employee_model->dpdown_status();
$data['attainment'] = $this->employee_model->dpdown_attainment();
$rules = $this->employee_model->rules['insert'];
$this->form_validation->set_rules($rules);
if ($this->form_validation->run() == TRUE)
{
$post = $this->employee_model->array_from_post(array(
'ID_number',
'employee_no',
'department_id',
'department_position',
'tin_number',
'sss_number',
'ph_number',
'first_name',
'middle_name',
'last_name',
'suffix_name',
'street',
'barangay',
'city',
'zipcode',
'birthday',
'age',
'gender_id',
'nationality',
'religion',
'status_id',
'telephone_number',
'cellphone_number',
'email',
'educational_att_id',
'diploma_title',
'school_name',
'year_graduated',
'company1_name',
'position1_title',
'inclusive_dates1',
'company2_name',
'position2_title',
'inclusive_dates2',
'company3_name',
'position3_title',
'inclusive_dates3',
'date_employed'
));
$data = $this->employee_model->save($post);
return self::redirect_to('human_resource/admin', '<b>Success</b><br>New Admin Employee has been successfully Registered.');
}
$data['error'] = validation_errors('<li class="error">', '</li>');
$data['content'] = 'human_resource/actions/add_admin';
return $this->load->view('templates', $data);
}
and then this is how my model looks like (employee_model.php)
these are for my rules
public $rules = array('insert' => array(
'department_position' => array(
'field' => 'department_position',
'label' => 'Employee Position',
'rules' => 'trim|required',
'errors' => array('required' => 'This Field is Required')),
'ID_number' => array(
'field' => 'ID_number',
'label' => 'ID Number',
'rules' => 'trim|required',
'errors' => array('required' => 'This Field is Required')),
'employee_no' => array(
'field' => 'employee_no',
'label' => 'Employee Number',
'rules' => 'trim|required',
'errors' => array('required' => 'This Field is Required')),
'tin_number' => array(
'field' => 'tin_number',
'label' => 'Tin Number',
'rules' => 'trim|required',
'errors' => array('required' => 'This Field is Required')),
'sss_number' => array(
'field' => 'sss_number',
'label' => 'SSS Number',
'rules' => 'trim|required',
'errors' => array('required' => 'This Field is Required')),
'ph_number' => array(
'field' => 'ph_number',
'label' => 'Phil Health Number',
'rules' => 'trim|required',
'errors' => array('required' => 'This Field is Required')),));
then this is my save function still inside the same model
public function save($post, $employee_id = NULL)
{
if($this->timestamp == TRUE)
{
$now = date('Y-m-d H:i:s');
$employee_id || $post['created_at'] = $now;
$post['updated_at'] = $now;
}
if($employee_id === NULL)
{
!isset($post[$this->primary_key]) || $post[$this->primary_key] = NULL;
$this->db->insert($this->table_name, $post);
$employee_id = $this->db->insert_id();
}else{
$filter = $this->filter;
$this->db->where($this->primary_key, $filter($employee_id))
->update($this->table_name, $post);
}
}
then this is my view form
i did not put all in here just the 1/4 of my view code
<div class="main-content">
<div class="main-content-inner">
<div class="breadcrumbs ace-save-state" id="breadcrumbs">
<ul class="breadcrumb">
<li>
<i class="ace-icon fa fa-tachometer home-icon"></i>
Dashboard
</li>
<li>
<i class="ace-icon fa fa-user home-icon"></i>
Administration Table
</li>
<li>
New Admin Form
</li>
<li class="active">Application Form</li>
</ul>
</div>
<!-- /end of breadcrumb -->
<div class="page-content">
<div class="page-header">
<h1>
<i class="fa fa-user-plus"></i>
New Admin Form
<small>
<i class="ace-icon fa fa-angle-double-right"></i>
Application Form
</small>
</h1>
</div>
<!-- end of page header -->
<?php echo form_open(NULL, array('class' => 'form-horizontal', 'role' => 'form'));?>
<div class="row">
<div class="col-xs-12">
<!-- table content -->
<div class="widget-box">
<div class="widget-header widget-header-blue widget-header-flat">
<h4 class="widget-title lighter">Form Wizard</h4>
</div>
<!-- end of widget header -->
<!-- R-1 -->
<div class="widget-body">
<div class="widget-main" style="padding-bottom: 0;">
<h4 class="lighter block green">Employee General Information
<span class="help-button" style="background-color: red;" data-rel="popover" data-trigger="hover" data-placement="right" data-content="If a field is not applicable please type N/A" title="Notice!">
<i class="fa fa-exclamation"></i>
</span>
</h4>
<div class="row">
<!-- B-1 col -->
<div class="col-xs-12 col-sm-4">
<div class="widget-box">
<div class="widget-header">
<h5 class="widget-title">General Information</h5>
</div>
<!-- end of widget header -->
<div class="widget-body">
<div class="widget-main">
<!-- employee information B-1-->
<!-- first name -->
<?php echo form_label('First Name', 'first_name', array('class' => 'control-label'));?>
<span style="font-weight: bolder; color: red;">*</span>
<div class="form-group <?php if (form_error('first_name')==TRUE){echo 'has-error';} ?>" style="margin-bottom: 0;">
<div class="col-sm-12">
<?php echo form_input('first_name', set_value('first_name', $employee->first_name),
array( 'type' => 'text',
'name' => 'first_name',
'id' => 'firstname',
'class' => 'form-control')); ?>
</div>
</div>
<!-- validation -->
<?php if (!empty($error)): ?>
<div class="has-error" style="margin-bottom: 0;">
<div class="help-block col-xs-12 col-sm-reset inline"
style="margin-bottom: 0; font-size: 12px;">
<?php echo form_error('first_name'); ?>
</div>
</div>
<?php endif ?>
<!-- last name -->
<?php echo form_label('Last Name', 'last_name', array('class' => 'control-label'));?>
<span style="font-weight: bolder; color: red;">*</span>
<div class="form-group <?php if (form_error('last_name')==TRUE){echo 'has-error';} ?>" style="margin-bottom: 0;">
<div class="col-sm-12">
<?php echo form_input('last_name', set_value('last_name', $employee->last_name),
array( 'type' => 'text',
'name' => 'last_name',
'id' => 'lastname',
'class' => 'form-control'));?>
</div>
</div>
<!-- validation -->
<?php if (!empty($error)): ?>
<div class="has-error" style="margin-bottom: 0;">
<div class="help-block col-xs-12 col-sm-reset inline"
style="margin-bottom: 0; font-size: 12px;">
<?php echo form_error('last_name'); ?>
</div>
</div>
<?php endif ?>
<!-- middle name -->
<?php echo form_label('Middle Name', 'middle_name', array('class' => 'control-label'));?>
<span style="font-weight: bolder; color: red;">*</span>
<div class="form-group <?php if (form_error('middle_name')==TRUE){echo 'has-error';} ?>" style="margin-bottom: 0;">
<div class="col-sm-12">
<?php echo form_input('middle_name', set_value('middle_name', $employee->middle_name),
array( 'type' => 'text',
'name' => 'middle_name',
'id' => 'middlename',
'class' => 'form-control'));?>
</div>
</div>
<!-- validation -->
<?php if (!empty($error)): ?>
<div class="has-error" style="margin-bottom: 0;">
<div class="help-block col-xs-12 col-sm-reset inline"
style="margin-bottom: 0; font-size: 12px;">
<?php echo form_error('middle_name'); ?>
</div>
</div>
<?php endif ?>
<!-- suffix name -->
<?php echo form_label('Suffix', 'suffix_name', array('class' => 'control-label'));?>
<div class="form-group" style="margin-bottom: 0;">
<div class="col-sm-6">
<?php echo form_input('suffix_name', set_value('suffix_name', $employee->suffix_name),
array( 'type' => 'text',
'name' => 'suffix_name',
'id' => 'suffixname',
'class' => 'form-control'));?>
</div>
</div>
<hr>
</div>
</div>
</div>
</div>
<!-- end of B-1 col -->
please anyone i really need your help
You need to use form_open_multipart
This function is absolutely identical to form_open() ... , except that
it adds a multipart attribute, which is necessary if you would like to
use the form to upload files with.
Ref: https://www.codeigniter.com/user_guide/helpers/form_helper.html
I have a datepicker form using bootstrap, but when I click on it, it does not show the date on the popup (the popup is truncated).
Code of the script :
// Date Picker
jQuery('#datepicker').datepicker();
jQuery('#datepicker-autoclose').datepicker({
autoclose: true,
todayHighlight: true
});
and then the result of click comes out as below:
I use codeigniter and this is my controller :
function save()
{
$this->template->set_title('Pickup');
$this->breadcrumbs->push('Pickup', 'pickup');
$this->breadcrumbs->push('Create Pickup', '/pickup/list');
$this->breadcrumbs->push('Save', '/pickup/add');
// JS Init
$js_init = "";
// Include CSS & JS
$this->template->add_init($js_init);
$this->template->add_includes('css', 'assets/plugins/bootstrap-datepicker/css/bootstrap-datepicker.min.css');
$this->template->add_includes('css', 'assets/plugins/clockpicker/css/bootstrap-clockpicker.min.css');
$this->template->add_includes('js', 'assets/plugins/moment/moment.js');
$this->template->add_includes('js', 'assets/plugins/timepicker/bootstrap-timepicker.js');
$this->template->add_includes('js', 'assets/plugins/bootstrap-datepicker/js/bootstrap-datepicker.min.js');
$this->template->add_includes('js', 'assets/plugins/clockpicker/js/bootstrap-clockpicker.min.js');
$this->template->add_includes('js', 'assets/plugins/clockpicker/js/bootstrap-clockpicker.min.js');
$this->template->add_includes('js', 'assets/js/popper.min.js');
$this->template->add_includes('js', 'assets/pages/jquery.form-pickers.init.js');
$this->template->add_includes('js', 'assets/plugins/validator/validator.min.js');
if (!$this->ion_auth->logged_in())
{
redirect('auth', 'refresh');
}
// validate form input
$this->form_validation->set_rules('pickup_code', 'Pickup Code', 'required');
$this->form_validation->set_rules('pickup_date','Date', 'required');
$this->form_validation->set_rules('pickup_address', 'Address', 'required');
// serial number untuk pickup
$serial = $this->MY_Model->generate_number($this->tables,$this->pk,'10','PCK');
if ($this->form_validation->run() == TRUE)
{
$data = array(
'pickup_code' =>$this->input->post('pickup_code'),
'pickup_date' =>$this->input->post('pickup_date'),
'pickup_address' =>$this->input->post('pickup_address')
);
$new_supplier = $this->MY_Model->insert($this->tables,$data);
redirect("pickup/listing", 'refresh');
}
else
{
$this->data['pickup_code'] = array(
'name' => 'pickup_code',
'id' => 'pickup_code',
'type' => 'text',
'data-error' => 'Please enter pickup code.',
'class' => 'form-control',
'required' => 'required',
'value' => $this->form_validation->set_value('pickup_code',$serial),
'readonly' => 'readonly',
);
$this->data['pickup_date'] = array(
'name' => 'pickup_date',
'id' => 'datepicker',
'type' => 'text',
'data-error' => 'Please enter pickup date.',
'class' => 'form-control',
'required' => 'required',
'value' => $this->form_validation->set_value('pickup_date'),
);
$this->data['pickup_note'] = array(
'name' => 'pickup_note',
'id' => 'pickup_note',
'type' => 'text',
'data-error' => 'Please enter note.',
'class' => 'form-control',
'value' => $this->form_validation->set_value('pickup_note'),
);
$this->data['pickup_address'] = array(
'name' => 'pickup_address',
'id' => 'pickup_address',
'type' => 'text',
'data-error' => 'Please enter address.',
'class' => 'form-control',
'required' => 'required',
'value' => $this->form_validation->set_value('pickup_address'),
);
$this->template->load('templates/Template',$this->folder.'/add',$this->data);
}
}
and this is my view :
<div class="row">
<div class="col-sm-12">
<div class="card-box">
<?php echo form_open("pickup/save_pickup","data-toggle='validator'");?>
<h4 class="m-t-0 header-title"><b>Pickup Save</b></h4>
<p class="text-muted m-b-30 font-13">
<?php echo lang('create_group_subheading');?>
</p>
<?php if ($this->session->flashdata('message')) {?>
<div class='alert alert-danger alert-dismissable'>
<?php echo $this->session->flashdata('message'); ?>
</div>
<?php }?>
<div class="row">
<div class="col-md-6">
<div class="p-20">
<div class="form-group">
<label for="group_name"> Pickup Code
<?php ?>
<span class="text-danger">*</span></label>
<?php echo form_input($pickup_code);?>
<p class="help-block with-errors text-danger"></p>
</div>
<div class="form-group">
<label for="description"> Date
</label>
<span class="text-danger">*</span></label>
<?php echo form_input($pickup_date);?>
<div class="help-block with-errors text-danger"></div>
</div>
<div class="form-group">
<label for="description"> Note
</label>
<?php echo form_textarea($pickup_note);?>
<div class="help-block with-errors text-danger"></div>
</div>
<div class="form-group">
<label for="description"> Address
</label>
<span class="text-danger">*</span></label>
<?php echo form_textarea($pickup_address);?>
<div class="help-block with-errors text-danger"></div>
</div>
</div>
</div>
</div>
<div class="form-group text-right m-b-0">
<button class="btn btn-primary waves-effect waves-light" type="submit">
<i class="fa fa-save m-r-5"></i> <span>Save</span>
</button>
<a href="<?php echo base_url('pickup'); ?>" class="btn btn-secondary waves-effect m-l-5">
<i class="fa fa-reply m-r-5"></i> <span>Cancel</span>
</a>
<?php echo form_close();?>
</div>
</div>
</div>
I want to add some nice bottstrap html and css to my register page, but i don't know how to embedding php into html input and show it with style. Is there any way to do this?
The code produces the next view:
Full .php file
Note: it is showing both forms(to compare results), php and html + php. form with only php works fine, the problem is to give it style.
<?php defined('BASEPATH') OR exit('No direct script access allowed');?>
<link rel="stylesheet" href="<?= base_url('assets/bootstrap2/bootstrap.min.css'); ?>">
<link rel="stylesheet" href="<?= base_url('assets/bootstrap2/bootstrap.css'); ?>">
<link rel="stylesheet" href="<?= base_url('assets/js2/bootstrap.js'); ?>">
<link rel="stylesheet" href="<?= base_url('assets/js2/bootstrap.min.js'); ?>">
<div class="container">
<?php
echo isset($_SESSION['auth_message']) ? $_SESSION['auth_message'] : FALSE;
?>
<h1>Registro usuario</h1>
<?php
echo form_open();
echo form_label('Nombre:','first_name').'<br />';
echo form_error('first_name');
echo form_input('first_name',set_value('first_name')).'<br />';
echo form_label('Apellidos:','last_name').'<br />';
echo form_error('last_name');
echo form_input('last_name',set_value('last_name')).'<br />';
// echo form_label('Username:','username').'<br />';
//echo form_error('username');
//echo form_input('username',set_value('username')).'<br />';
echo form_label('Email:','email').'<br />';
echo form_error('email');
echo form_input('email',set_value('email')).'<br />';
echo form_label('Contraseña:', 'password').'<br />';
echo form_error('password');
echo form_password('password').'<br />';
echo form_label('Confirmar contraseña:', 'confirm_password').'<br />';
echo form_error('confirm_password');
echo form_password('confirm_password').'<br /><br />';
echo form_submit('register','Confirmar');
echo form_close();
?>
</div>
<form class="form-horizontal">
<fieldset>
<!-- Form Name -->
<legend>Registro de usuario</legend>
<!-- Text input-->
<div class="form-group">
<label class="col-md-4 control-label" for="textinput">Nombre</label>
<div class="col-md-4">
<!-- <input value="" id="textinput" name="textinput" type="text" placeholder="Ej: José Manuel..." class="form-control input-md" required=""> -->
<?php $nombre = array(
'name' => 'first_name',
'id' => 'first_name',
'type' => 'text',
'class' => 'form-control input-md',
'placeholder' => 'Ej: José Manuel...',
); ?>
<?php echo form_input($nombre); ?>
<!-- <?php echo form_input('first_name',set_value('first_name')); ?> -->
</div>
</div>
<!-- Text input-->
<div class="form-group">
<label class="col-md-4 control-label" for="textinput">Apellidos</label>
<div class="col-md-4">
<!-- <input value="" id="textinput" name="textinput" type="text" placeholder="Ej: Palma..." class="form-control input-md" required=""> -->
<?php $apellidos = array(
'name' => 'last_name',
'id' => 'last_name',
'type' => 'text',
'class' => 'form-control input-md',
'placeholder' => 'Ej: Palma...',
); ?>
<?php echo form_input($apellidos); ?>
<!-- <?php echo form_input('last_name',set_value('last_name')); ?> -->
</div>
</div>
<!-- Text input-->
<div class="form-group">
<label class="col-md-4 control-label" for="textinput">Email</label>
<div class="col-md-4">
<!-- <input value="" id="textinput" name="textinput" type="text" placeholder="Ej: herba#gmail.com..." class="form-control input-md" required=""> -->
<?php $email = array(
'name' => 'email',
'id' => 'email',
'type' => 'text',
'class' => 'form-control input-md',
'placeholder' => 'Ej: herba#gmail.com...',
); ?>
<?php echo form_input($email); ?>
<!-- <?php echo form_input('email',set_value('email'));?> -->
</div>
</div>
<!-- Password input-->
<div class="form-group">
<label class="col-md-4 control-label" for="passwordinput">Contraseña</label>
<div class="col-md-4">
<!-- <input value="" id="passwordinput" name="passwordinput" type="password" placeholder="Ej: herbaricemills9..." class="form-control input-md" required=""> -->
<?php $password = array(
'name' => 'password',
'id' => 'password',
'type' => 'password',
'class' => 'form-control input-md',
'placeholder' => 'Ej: herbaricemills9...',
); ?>
<?php echo form_input($password); ?>
<!-- <?php echo form_password('password'); ?> -->
</div>
</div>
<!-- Password input-->
<div class="form-group">
<label class="col-md-4 control-label" for="passwordinput">Confirmar contraseña</label>
<div class="col-md-4">
<!-- <input value="" id="passwordinput" name="passwordinput" type="password" placeholder="Repetir contraseña..." class="form-control input-md" required=""> -->
<?php $password1 = array(
'name' => 'confirm_password',
'id' => 'confirm_password',
'type' => 'password',
'class' => 'form-control input-md',
'placeholder' => 'Repetir contraseña...',
); ?>
<?php echo form_input($password1); ?>
<!-- <?php echo form_password('confirm_password');?> -->
</div>
</div>
<!-- Button -->
<div class="form-group">
<label class="col-md-4 control-label" for="singlebutton"></label>
<div class="col-md-4">
<!-- <button value="" id="singlebutton" name="singlebutton" class="btn btn-primary">Confirmar</button> -->
<!-- <?php $confirm = array(
'name' => 'singlebutton',
'id' => 'singlebutton',
//'type' => 'password',
'class' => 'btn btn-primary',
); ?>
<?php echo form_input($confirm); ?> -->
<?php echo form_submit('register','Confirmar');?>
</div>
</div>
</fieldset>
</form>
for inserting this
<input value="" id="textinput" name="textinput" type="text" placeholder="Ej: herba#gmail.com..." class="form-control input-md" required="">
try to use this example:
$data = array(
'name' => 'textinput',
'id' => 'textinput',
'type' => 'text',
'class' => 'form-control input-md',
'placeholder' => 'Ej: herba#gmail.com...',
);
echo form_input($data);
you can use like below.
for example first_name field
$data = array(
'name' => 'first_name',
'id' => 'first_name',
'type' => 'text',
'class' => 'form-control input-md',
'placeholder' => 'Enter First Name',
);
echo form_input($data);
use same for other element too.
i have created a form in yii2 basic and used material design to enable floating labels but its labels are not floating above when i click the input field. Here is my code for form.
<?php
$form = ActiveForm::begin([
'action' => ['index'],
'method' => 'get',
]);
?>
<div class="panel-body container-fluid">
<div class="row">
<div class="col-md-12">
<div class="col-xs-6 col-lg-6">
<div class="form-group form-material floating" data-plugin="formMaterial">
<?= $form->field($model, 'corporation_name',[ 'labelOptions' => [ 'class' => 'floating-label' ]])->textInput(['maxlength' => true, 'class' => 'form-control'])->label('Corporation Name') ?>
</div>
<div class="form-group form-material floating" data-plugin="formMaterial">
<?= $form->field($model, 'user_first_name',[ 'labelOptions' => [ 'class' => 'floating-label' ]])->textinput(['class' => 'form-control'])->label('Corporation Admin'); ?>
</div>
</div>
<div class="col-xs-6 col-lg-6">
<div class="form-group form-material floating" data-plugin="formMaterial">
<div class="example"> <b role="presentation"></b>
<?= $form->field($model, 'corporation_status')->dropDownList(Yii::$app->appstatues->status, ['prompt' => 'Status'])->label(false); ?>
</div>
</div>
</div>
</div>
<div class="col-md-12">
<div class="form-group form-material floating m-t-27" data-plugin="formMaterial">
<?= Html::submitButton('Search', ['class' => 'btn-primary btn waves-effect waves-light waves-effect']) ?>
<?= Html::resetButton('Reset', ['class' => 'btn-primary btn waves-effect waves-light waves-effect', 'onclick' => 'location.href = "/admin/corporations";']) ?>
</div>
</div>
</div>
</div>
<?php ActiveForm::end(); ?>
</div>
can anybody tell what am i doing wrong?
Have you look in inspect element?
If I understand you well...
Try to remove divs around input form. When you bind form for model you already have divs around input. Try this...
<?= $form->field($model, 'ime',['options'=>['class'=>'form-group form-material floating', 'data-plugin'=> 'formMaterial'], 'labelOptions' => [ 'class' => 'floating-label' ]])->textInput(['maxlength' => true, 'class' => 'form-control'])->label('Corporation Name') ?>