Bootstrap datepicker does not show date on popup - php

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>

Related

I want to add upload image code to my form

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

save message is not displayed in yii form

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>

CodeIgniter-Ion-Auth adding user using modal

I am new to Ion Auth codeigniter library. Now I am making a custom bootstrap form to add a user using modal but I always get errors. Any help would be much appreciated. The modal is inside the userList.php view that displays all registered users.
Controller: Users.php
function create_user()
{
$this->data['title'] = "Create User";
if (!$this->ion_auth->logged_in() || !$this->ion_auth->is_admin())
{
redirect('auth', 'refresh');
}
$tables = $this->config->item('tables','ion_auth');
$identity_column = $this->config->item('identity','ion_auth');
$this->data['identity_column'] = $identity_column;
// validate form input
$this->form_validation->set_rules('first_name', $this->lang->line('create_user_validation_fname_label'), 'required');
$this->form_validation->set_rules('last_name', $this->lang->line('create_user_validation_lname_label'), 'required');
if($identity_column!=='email')
{
$this->form_validation->set_rules('identity',$this->lang->line('create_user_validation_identity_label'),'required|is_unique['.$tables['users'].'.'.$identity_column.']');
$this->form_validation->set_rules('email', $this->lang->line('create_user_validation_email_label'), 'required|valid_email');
}
else
{
$this->form_validation->set_rules('email', $this->lang->line('create_user_validation_email_label'), 'required|valid_email|is_unique[' . $tables['users'] . '.email]');
}
$this->form_validation->set_rules('phone', $this->lang->line('create_user_validation_phone_label'), 'trim');
$this->form_validation->set_rules('company', $this->lang->line('create_user_validation_company_label'), 'trim');
$this->form_validation->set_rules('password', $this->lang->line('create_user_validation_password_label'), 'required|min_length[' . $this->config->item('min_password_length', 'ion_auth') . ']|max_length[' . $this->config->item('max_password_length', 'ion_auth') . ']|matches[password_confirm]');
$this->form_validation->set_rules('password_confirm', $this->lang->line('create_user_validation_password_confirm_label'), 'required');
if ($this->form_validation->run() == true)
{
$email = strtolower($this->input->post('email'));
$identity = ($identity_column==='email') ? $email : $this->input->post('identity');
$password = $this->input->post('password');
$additional_data = array(
'first_name' => $this->input->post('first_name'),
'last_name' => $this->input->post('last_name'),
'company' => $this->input->post('company'),
'phone' => $this->input->post('phone'),
);
var_dump($first_name);
}
if ($this->form_validation->run() == true && $this->ion_auth->register($identity, $password, $email, $additional_data))
{
// check to see if we are creating the user
// redirect them back to the admin page
$this->session->set_flashdata('message', $this->ion_auth->messages());
redirect("auth", 'refresh');
}
else
{
// display the create user form
// set the flash data error message if there is one
$this->data['message'] = (validation_errors() ? validation_errors() : ($this->ion_auth->errors() ? $this->ion_auth->errors() : $this->session->flashdata('message')));
$this->data['first_name'] = array(
'name' => 'first_name',
'id' => 'first_name',
'type' => 'text',
'value' => $this->form_validation->set_value('first_name'),
);
$this->data['last_name'] = array(
'name' => 'last_name',
'id' => 'last_name',
'type' => 'text',
'value' => $this->form_validation->set_value('last_name'),
);
$this->data['identity'] = array(
'name' => 'identity',
'id' => 'identity',
'type' => 'text',
'value' => $this->form_validation->set_value('identity'),
);
$this->data['email'] = array(
'name' => 'email',
'id' => 'email',
'type' => 'text',
'value' => $this->form_validation->set_value('email'),
);
$this->data['company'] = array(
'name' => 'company',
'id' => 'company',
'type' => 'text',
'value' => $this->form_validation->set_value('company'),
);
$this->data['phone'] = array(
'name' => 'phone',
'id' => 'phone',
'type' => 'text',
'value' => $this->form_validation->set_value('phone'),
);
$this->data['password'] = array(
'name' => 'password',
'id' => 'password',
'type' => 'password',
'value' => $this->form_validation->set_value('password'),
);
$this->data['password_confirm'] = array(
'name' => 'password_confirm',
'id' => 'password_confirm',
'type' => 'password',
'value' => $this->form_validation->set_value('password_confirm'),
);
$this->_render_page('userList', $this->data);
}
}
View: userList.php
<div class="modal fade" id="add-user" role="dialog">
<div class="modal-dialog modal-default">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 id="modal-user-profile" class="modal-title">Add User</h4>
</div>
<div class="modal-body">
<?php echo form_open('users/create_user', ['class' => 'form-horizontal', 'role' => 'form']); ?>
<div class="form-group">
<label for="first_name" class="col-sm-2 control-label">First Name</label>
<div class="col-sm-10">
<?php echo form_input($first_name);?>
</div>
</div>
<div class="form-group">
<label for="password" class="col-sm-2 control-label">Password</label>
<div class="col-sm-10">
<?php echo form_password(['name' => 'password', 'id' => 'password', 'class' => 'form-control', 'placeholder' => 'Password']); ?>
</div>
</div>
<div class="form-group">
<label for="password" class="col-sm-2 control-label">Confirm Password</label>
<div class="col-sm-10">
<?php echo form_password(['name' => 'password_confirm', 'id' => 'password_confirm', 'class' => 'form-control', 'value' => set_value('password_confirm'), 'placeholder' => 'Confirm Password']); ?>
</div>
</div>
<div class="form-group">
<label for="email" class="col-sm-2 control-label">Email</label>
<div class="col-sm-10">
<?php echo form_input(['name' => 'email', 'id' => 'email', 'class' => 'form-control', 'value' => set_value('email'), 'placeholder' => 'Email']); ?>
</div>
</div>
<div class="form-group">
<label for="email" class="col-sm-2 control-label">Contact No</label>
<div class="col-sm-10">
<?php echo form_input(['name' => 'contact', 'id' => 'contact', 'class' => 'form-control', 'value' => set_value('contact'), 'placeholder' => 'Contact']); ?>
</div>
</div>
<div class="form-group">
<label for="status" class="col-sm-2 control-label">Group</label>
<div class="col-sm-10">
<select class="form-control" id="group">
<option>--</option>
<option>Admin</option>
<option>Client</option>
<option>BIR</option>
</select>
</div>
</div>
<div class="form-group">
<label for="status" class="col-sm-2 control-label">Status</label>
<div class="col-sm-10">
<select class="form-control" id="status">
<option>--</option>
<option>Active</option>
<option>Inactive</option>
</select>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-default create-user">Create</button>
<button type="button" class="btn btn-danger create">Cancel</button>
</div>
</div>
<?php echo form_close(); ?>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
What errors are you getting??
In your controller, Use this to verify your results
After query;
echo $this->db->last_query();
var_dump($_POST);exit;
First check all the post data and the query and tell the errors you're getting

Upload photo with thumbnail preview, using codeigniter

How can i make a registration form where i upload an image for my profile picture, and before clicking register, there's a preview of the image that i want to set as the profile picture using CI??
here's my registration form code
register_model.php
<?php
class Register_model extends CI_Model
{
function create_user($photo_name)
{
$new_user_insert_data = array(
'id' => '',
'email' => $this->input->post('email'),
'password' => md5($this->input->post('password')),
'name' => $this->input->post('name'),
'major' => $this->input->post('user_major'),
'year' => $this->input->post('user_year'),
'bio' => $this->input->post('bio'),
'profpic' => $photo_name,
'insta' => $this->input->post('instagram'),
'twitter' => $this->input->post('twitter'),
'facebook' => $this->input->post('facebook'),
'vote_count' => '10',
'vote' => '0',
'gender' => $this->input->post('gender'),
);
$insert = $this->db->insert('user', $new_user_insert_data);
return $insert;
}
}
?>
Here's the view
register.php
<div class="margin-top-87">
<div class="container">
<h1>Register</h1>
<hr>
<div class="row">
<!-- left column -->
<div class="col-md-3">
<div class="text-center">
<img src="//placehold.it/100" class="avatar img-circle" alt="avatar">
<?php
if(!empty($_FILES['userfile'])){
$name_array = array();
$count = count($_FILES['userfile']['size']);
foreach($_FILES as $key => $value)
for ($s=0; $s<=$count-1; $s++)
{
//Original Image Upload - Start
$_FILES['userfile']['name'] = $value['name'][$s];
$_FILES['userfile']['type'] = $value['type'][$s];
$_FILES['userfile']['tmp_name'] = $value['tmp_name'][$s];
$_FILES['userfile']['error'] = $value['error'][$s];
$_FILES['userfile']['size'] = $value['size'][$s];
$config['upload_path'] = './public/images/campaign-images/';
$config['allowed_types'] = 'gif|jpg|jpeg|png|GIF|JPG|JPEG|PNG';
$config['max_size'] = '10000';
//$config['max_width'] = '1024';
//$config['max_height'] = '768';
$CI->load->library('upload', $config);
$CI->upload->do_upload();
$data = $CI->upload->data();
//Original Image Upload - End
//Thumbnail Image Upload - Start
$config['image_library'] = 'gd2';
$config['source_image'] = './public/images/campaign-images/'. $value['name'][$s];
$config['new_image'] = './public/images/campaign-images/thumbs/'.$value['name'][$s];
$config['width'] = 350;
$config['height'] = 250;
//load resize library
$this->load->library('image_lib', $config);
$this->image_lib->resize();
//Thumbnail Image Upload - End
$name_array[] = $data['file_name'];
}
return $name_array;
}
?>
<h6>Please use real photo, not an avatar</h6>
<?php
$data= array
(
'name' => 'userfile',
'type' => 'file',
'class' => 'form-control',
'id' => 'form_register'
);
echo form_upload($data);
?>
</div>
</div>
<!-- edit form column -->
<div class="col-md-9 personal-info">
<div class="alert alert-info fade in">
<strong>Info!</strong> Please fill with real information of yours.
</div>
<?php
if(validation_errors('<p class="error">'!=""))
{?>
<div class="alert alert-danger fade in">
×
<strong>Attention!</strong> <?php echo validation_errors('<p class="error">') ?>
</div><?php
}?>
<h3>Personal info</h3>
<?php $attributes = array('class' => 'form-horizontal', 'role' => 'form', 'id' => 'form_register'); echo form_open('index/create_user',$attributes); ?>
<div class="form-group">
<label class="col-lg-3 control-label">UC Student email :</label>
<div class="col-lg-8">
<?php
$data= array
(
'name' => 'email',
'placeholder' => 'Ciputra student email. Example : email#student.ciputra.ac.id',
'type' => 'email',
'class' => 'form-control',
'required' => 'required'
);
echo form_input($data);
?>
</div>
</div>
<div class="form-group">
<label class="col-lg-3 control-label">Name :</label>
<div class="col-lg-8">
<?php
$data= array
(
'name' => 'name',
'placeholder' => 'Full name. Example : Front Middle Last',
'type' => 'text',
'class' => 'form-control',
'required' => 'required'
);
echo form_input($data);
?>
</div>
</div>
<div class="form-group">
<label class="col-lg-3 control-label">Gender :</label>
<div class="col-lg-8">
<div class="ui-select">
<?php
$options = array
(
'' => 'Gender',
'Man' => 'Man',
'Woman' => 'Woman'
);
echo form_dropdown('gender', $options, '', 'class="form-control"');
?>
</div>
</div>
</div>
<div class="form-group">
<label class="col-lg-3 control-label">Major :</label>
<div class="col-lg-8">
<div class="ui-select">
<?php
$options = array
(
'' => 'Insert your major',
'CB' => 'CB',
'FDB' => 'FDB',
'IBM-IC' => 'IBM-IC',
'IBM-RC' => 'IBM-RC',
'IBA' => 'IBA',
'IHTB' => 'IHTB',
'IMT' => 'IMT',
'INA' => 'INA',
'MCM' => 'MCM',
'MIS' => 'MIS',
'PSY' => 'PSY',
'VCD' => 'VCD'
);
echo form_dropdown('user_major', $options, '', 'class="form-control"');
?>
</div>
</div>
</div>
<div class="form-group">
<label class="col-lg-3 control-label">Year :</label>
<div class="col-lg-8">
<div class="ui-select">
<?php
$options = array('' => 'Year joined UC');
for ($i = date('Y'); $i >= 2006; $i--)
{
$options[$i] = $i;
}
echo form_dropdown('user_year', $options, '', 'class="form-control"');
?>
</div>
</div>
</div>
<div class="form-group">
<label class="col-md-3 control-label">Password :</label>
<div class="col-md-8">
<?php
$data= array
(
'name' => 'password',
'placeholder' => 'Password',
'type' => 'password',
'class' => 'form-control',
'required' => 'required',
'maxlength' => '15'
);
echo form_password($data);
?>
</div>
</div>
<div class="form-group">
<label class="col-md-3 control-label">Confirm password :</label>
<div class="col-md-8">
<?php
$data= array
(
'name' => 'cpassword',
'placeholder' => 'Confirm Password',
'type' => 'password',
'class' => 'form-control',
'required' => 'required',
'maxlength' => '15'
);
echo form_password($data);
?>
</div>
</div>
<div class="form-group">
<label class="col-lg-3 control-label">Short Bio :</label>
<div class="col-lg-8">
<?php
$data= array
(
'name' => 'bio',
'placeholder' => 'Short bio (max 128 character)',
'type' => 'text',
'class' => 'form-control',
'maxlength' => '128',
'rows' => '3'
);
echo form_textarea($data);
?>
</div>
</div>
<div class="form-group">
<label class="col-lg-3 control-label">Facebook :</label>
<div class="col-lg-8">
<?php
$data= array
(
'name' => 'facebook',
'placeholder' => 'Facebook Profile link. Example : facebook.com/name',
'type' => 'url',
'class' => 'form-control',
);
echo form_input($data);
?>
</div>
</div>
<div class="form-group">
<label class="col-lg-3 control-label">Twitter :</label>
<div class="col-lg-8">
<?php
$data= array
(
'name' => 'twitter',
'placeholder' => 'Twitter Profile link. Example : #name',
'type' => 'url',
'class' => 'form-control',
);
echo form_input($data);
?>
</div>
</div>
<div class="form-group">
<label class="col-lg-3 control-label">Instagram :</label>
<div class="col-lg-8">
<?php
$data= array
(
'name' => 'instagram',
'placeholder' => 'Instagram Profile link. Example : #name',
'type' => 'url',
'class' => 'form-control',
);
echo form_input($data);
?>
</div>
</div>
<div class="form-group">
<label class="col-md-3 control-label"></label>
<div class="col-md-8">
<?php
$data= array
(
'name' => 'register',
'value' => 'Register',
'type' => 'submit',
'class' => 'btn btn-primary',
);
echo form_submit($data);
?>
<span></span>
<?php
$data= array
(
'name' => 'reset',
'value' => 'Clear',
'type' => 'reset',
'class' => 'btn btn-default',
);
echo form_reset($data);
?>
</div>
</div>
</form>
<?php echo form_close(); ?>
</div>
</div>
</div>
<hr>
</div>
The "preview before uploading" thing is a javascript trick that loads the local file into the <img> source. The rest is simple file upload where you check the file types, size, resolution etc.
Here is your answer: Preview an image before it is uploaded

How to load remote Modal content in yii2

I have been trying to load remote content for different bootstrap modal on same yii2 view
<?php
$label = $model->getAttributeLabel('educationId');
$addon = [
'prepend' => [
'content' => Html::icon('book')
],
'append' => [
'content' => Html::button(
Html::icon('plus'), [
'class' => 'btn btn-success',
'title' => 'Add New' . $label,
'onclick' => new JsExpression('showModal();'),
]
),
'asButton' => true
]
];
echo Html::tag('label',$model->getAttributeLabel('educationId'), ['class'=>'control-label']);
echo Select2::widget([
'model' => $model,
'attribute' => 'educationId',
'data' => ArrayHelper::map ( EducationLevel::find ()->all (), 'id', 'name' ),
'options' => ['placeholder' => 'Select Education Level ...','template' => 'label}\n{error}'],
'addon' => $addon,
'pluginOptions' => [
'maximumInputLength' => 10
],
]);
JS function
Function showModal(){
$('#addEducationModal').modal({
remote: 'modal.html',
show: true
});
}
So the user will click on the addon button of a text field and the modal will show up, and other text fields shall have same mechanism with different modal content.
However all what I get is faded background.
I was able to make it work and more than that.
The issue i had mainly because the yii cashes generated files so to resolve i deleted the generated files and made sure the content is generated fresh :)
and i havent used the JQuery load function.
see below code:
PHP View Code
$label = $model->getAttributeLabel('majorId');
$addon = [
'prepend' => [
'content' => Html::icon('book')
],
'append' => [
'content' => Html::button(Html::icon('plus'), [
'class' => 'btn btn-success',
'title' => 'Add New' . $label ,
'data-toggle' => 'modal',
'data-target' => '#addModal',
'href'=> 'addMajorModal.html',
]),
'asButton' => true
]
];
echo Html::tag('label',$model->getAttributeLabel('majorId'),['class'=>'control-label']);
echo Select2::widget([
'model' => $model,
'attribute' => 'majorId',
'data' =>ArrayHelper::map ( Major::find ()->all (), 'id', 'name' ),
'options' => ['placeholder' => 'Select Major ...','template' => 'label}\n{error}'],
'addon' => $addon,
'pluginOptions' => [
'maximumInputLength' => 10
],
]);
<div class="modal fade" id="addModal" >
<div class="modal-dialog" dir="rtl">
<div class="modal-content" dir="rtl">
<!-- Content will be loaded here from "addMajorModal.html" file -->
</div>
</div>
</div>
The Modal file content
<div class="modal-header panel-primary" dir="rtl" horizantal-aligned="">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel">إضا�ة جديد</h4>
</div>
<div class="modal-body" dir="rtl">
<div id="login-boxs" class="login-popup>
<form id="newCat" method="post" class="signin" dir="rtl" action="#">
<div class="form-group">
<label for="certName" class="control-label">مسمى التخصص </label>
<input type="text" name="name" data-val="true" data-val-required="ErrMsg" data-rule-required="true" placeholder="مسمى الشهادة" class="form-control" id="certName">
</div>
<div class="form-group">
<label for="certShortDesc" class="control-label">وص� قصير </label>
<input type="text" name="shdesc" data-rule-required="true" placeholder="وص� قصير" class="form-control" id="certShortDesc" required>
</div>
</form>
</div>
</div>
<div class="modal-footer" dir="rtl">
<div class="col-lg-6" dir="rtl">
<div class="progress" >
<div class="progress-bar progress-bar-striped" role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width: 100%;" id="progresBarUpload">
</div>
</div>
</div>
<div class="col-lg-6" dir="rtl">
<button type="button" class="btn btn-danger" dir="rtl" data-dismiss="modal"><i class="glyphicon glyphicon-remove"> </i>Close</button>
<button id="submitButton" type="button" dir="rtl" class="btn btn-primary" onclick="createCertificate()"><i class="glyphicon glyphicon-ok"> </i>Save changes</button>
</div>
</div>
Thats all, with this the modal will be loaded based on yii append generation of the HTML
As far as i know, this will be workable till Bootstrap 3.3 as remote content will be deprecated in version 4

Categories