I don't get "add button" with inline create on Backpack Laravel - php

Following this documentation : https://backpackforlaravel.com/docs/4.1/crud-operation-inline-create
I try to create a link between invoices (primary) and invoices lines (secondary).
The link seems good, but I don't succeed to have the "+add" button needed to have the secondary form.
My code.
Primary class (invoiceCrudController)
<?php
namespace App\Http\Controllers\Admin;
use App\Models\Invoice;
use Backpack\CRUD\app\Http\Controllers\CrudController;
/**
* Class InvoiceCrudController
* #package App\Http\Controllers\Admin
* #property-read \Backpack\CRUD\app\Library\CrudPanel\CrudPanel $crud
*/
class InvoiceCrudController extends CrudController
{
use \Backpack\CRUD\app\Http\Controllers\Operations\ListOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\CreateOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\UpdateOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\ShowOperation;
use SetAccesses;
protected function setupCreateOperation()
{
$this->crud->setValidation(InvoiceRequest::class);
$this->crud->addFields([
/*other cases*/
[
'name' => 'invoiceLines',
'type' => 'relationship',
'tags'=> 'invoice lines',
'ajax'=>true,
[ // specify the entity in singular
'entity' => 'invoiceLine', // the entity in singular
]
],
]);
}
protected function setupUpdateOperation()
{
$this->setupCreateOperation();
}
}
secondary class (invoiceLinesController)
<?php
namespace App\Http\Controllers\Admin;
use App\Models\InvoiceLine;
use Backpack\CRUD\app\Http\Controllers\CrudController;
/**
* Class InvoiceCrudController
* #package App\Http\Controllers\Admin
* #property-read \Backpack\CRUD\app\Library\CrudPanel\CrudPanel $crud
*/
class InvoiceLinesCrudController extends CrudController
{
use \Backpack\CRUD\app\Http\Controllers\Operations\CreateOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\InlineCreateOperation;
public function setup()
{
$this->setAccesses('invoiceLine');
$this->crud->setModel('App\Models\InvoiceLine');
$this->crud->setRoute(config('backpack.base.route_prefix') . '/invoiceLine');
$this->crud->setEntityNameStrings('invoiceLine', 'invoiceLines');
$this->crud->addColumns([
[
'name' => 'slug',
'type' => 'text',
],
[
'name' => 'quantity',
'type' => 'number',
'default' => 1,
'wrapper' => [
'class' => 'form-group col-sm-6 col-md-6 col-lg-3 col-xl-3'
]
],
[
'name' =>'unit_vat_excluded',
'type' => 'text',
'wrapper' => [
'class' => 'form-group col-sm-6 col-md-6 col-lg-3 col-xl-3'
]
]
]);
}
protected function setupListOperation()
{
$this->crud->enableExportButtons();
CustomerCrudController::addFilterCustomer();
}
protected function setupCreateOperation()
{
$this->crud->addFields([
[
'name' => 'slug',
'type' => 'text',
'allows_null' => false,
],
[
'name' => 'quantity',
'type' => 'number',
'default' => 1,
'wrapper' => [
'class' => 'form-group col-sm-6 col-md-6 col-lg-3 col-xl-3'
]
],
[
'name' =>'unit_vat_excluded',
'type' => 'text',
'wrapper' => [
'class' => 'form-group col-sm-6 col-md-6 col-lg-3 col-xl-3'
]
]
]);
}
protected function setupUpdateOperation()
{
$this->setupCreateOperation();
}
protected function setupShowOperation()
{
}
public static function getColumn()
{
return [
'name' => 'invoice_line_id',
'label' => 'InvoiceLines',
'type' => 'select',
'entity' => 'invoiceLine',
'attribute' => 'pretty_print',
'model' => InvoiceLine::class,
];
}
}

I think the wrong is in your Filed definistion:
$this->crud->addFields([
/other cases/
[
'name' => 'invoiceLines',
'type' => 'relationship',
'tags'=> 'invoice lines',
'ajax'=>true,
[ // specify the entity in singular
'entity' => 'invoiceLine', // the entity in singular
]
],
since the relation is on to many (I guess) then the filed should be:
[
'type' => "relationship",
'name' => 'invoiceLines',
'ajax' => true,
'inline_create' => true,
]

Related

laravel + mongo + gpaphql get children array

i have data in mongodb
it is a road object that has a property and an array of points that it consists of:
my model in laravel
<?php
namespace App\Models;
use App\Traits\Uuids;
use GraphQL\Type\Definition\Type;
use Rebing\GraphQL\Support\Facades\GraphQL;
use Jenssegers\Mongodb\Eloquent\Model as Eloquent;
class Road extends Eloquent
{
//use HasFactory;
use Uuids;
protected $connection = 'mongodb';
protected $collection = 'roads';
protected $fillable = ['id', 'roadId', 'code', 'name', 'points'];
#public $timestamps = false;
public $incrementing = false;
public function fields() : array
{
return [
'id' => [
'type' => Type::string(),
'description' => 'The identifier of the road',
],
'roadId' => [
'type' => Type::nonNull(Type::int()),
'description' => 'ID road of external database',
],
'code' => [
'type' => Type::string(),
'description' => 'code of document',
],
'name' => [
'type' => Type::nonNull(Type::string()),
'description' => 'road name',
],
'points' => [
'name' => 'points',
'description' => 'points of road',
'type' => GraphQL::type('RoadPoints'),
'is_relation' => false
]
];
}
}
here we refer to a new type of "point on the road"
GraphQL type 'RoadPoints':
<?php
namespace App\GraphQL\Types;
use App\Models\Address;
use App\Models\RoadPoints;
use GraphQL\Type\Definition\Type;
use Rebing\GraphQL\Support\Facades\GraphQL;
use Rebing\GraphQL\Support\Type as GraphQLType;
class RoadPointsType extends GraphQLType
{
protected $attributes = [
'name' => 'RoadPoints',
'description' => 'The points is defined by the format GeoJSON Point',
'model' => RoadPoints::class,
];
public function fields(): array
{
return [
'type' => [
'type' => Type::string(),
'description' => 'The format GeoJSON',
],
'pk' => [
'type' => Type::string(),
'description' => 'piket of point',
],
'coordinates' => [
'type' => Type::listOf(GraphQL::type('GeoJSON')),
'description' => 'The partner lat and lng',
]
];
}
}
laravel model of RoadPoints
model RoadPoints class :
<?php
namespace App\Models;
use Jenssegers\Mongodb\Eloquent\Model as Eloquent;
class RoadPoints extends Eloquent
{
protected $fillable = ['type', 'pk', 'coordinates'];
protected $casts = [
'coordinates' => 'array'
];
}
graphql RoadQuery :
<?php
namespace App\GraphQL\Queries;
use App\Models\Road;
use Closure;
use GraphQL\Type\Definition\Type;
use Rebing\GraphQL\Support\Query;
use App\Services\RoadService;
use GraphQL\Type\Definition\ResolveInfo;
use Rebing\GraphQL\Support\Facades\GraphQL;
class RoadQuery extends Query
{
private $roadService;
public function __construct(RoadService $roadService)
{
$this->roadService = $roadService;
}
protected $attributes = [
'name' => 'Road',
'description' => 'Query to Road data and points.'
];
public function type(): Type
{
return Type::listOf(GraphQL::type('Road'));
}
public function args(): array
{
return [
'id' => ['name' => 'id', 'type' => Type::string()],
'roadId' => ['name' => 'roadId', 'type' => Type::int()],
'code' => ['name' => 'code', 'type' => Type::string()],
'name' => ['name' => 'name', 'type' => Type::string()],
'lat' => ['name' => 'lat', 'type' => Type::float()],
'lng' => ['name' => 'lng', 'type' => Type::float()]
];
}
public function resolve($root, $args, $context, ResolveInfo $resolveInfo, Closure $getSelectFields)
{
$fields = $resolveInfo->getFieldSelection($depth = 3);
return $this->roadService->find($args, $fields);
}
}
result:
why pk and coordinates is null ?
Please tell me how to correctly select all objects in the array (points).
error in model
change
'type' => GraphQL::type('RoadPoints'),
to
'type' => Type::listOf(GraphQL::type('RoadPoints')),

How to use buttonOptions on GridView on Yii2

I would like to change the default button name on grid view On YII2
on Yii 1 we have this:
http://www.yiiframew...s-in-cgridview/
array
(
'class'=>'CButtonColumn',
'template'=>'{email}{down}{delete}',
'buttons'=>array
(
'email' => array
(
'label'=>'Send an e-mail to this user',
'imageUrl'=>Yii::app()->request->baseUrl.'/images/email.png',
'url'=>'Yii::app()->createUrl("users/email", array("id"=>$data->id))',
),
'down' => array
(
'label'=>'[-]',
'url'=>'"#"',
'visible'=>'$data->score > 0',
'click'=>'function(){alert("Going down!");}',
),
),
),
I would like something like that for Yii2
For now I would like to change only the label.
Reading the documentation for Yii2 I tried that:
[
'class' => 'yii\grid\ActionColumn',
'buttonOptions' => [
[
'name' => 'update',
'additionalOptions' => [
'label' => 'Super Update',
]
],
[
'name' => 'delete',
'additionalOptions' => [
'label' => 'Super Delete',
]
],
],
],
But it does not work.
I know I can recreate the button from scratch with :
'buttons' => [
'update' => function ($url, $model) {
$t = 'index.php?r=site/update&id='.$model->id;
return Html::button('<span class="glyphicon glyphicon-pencil"></span>', ['value'=>Url::to($t), 'class' => 'btn btn-default btn-xs']);
},
],
But I do not want to do that.
thanks
buttonOptions will be applied to all default buttons, you can't separate them, but it's possible to apply general options (to all buttons):
'class' => 'yii\grid\ActionColumn',
'buttonOptions' => [
'title' => 'This is custom title for default 3 buttons',
],
If you want to use custom HTML options, you'll have to create new class, extend ActionColumn and overwrite (2) protected methods, for example:
<?php
namespace app\models;
use yii\grid\ActionColumn;
use yii\helpers\Html;
use Yii;
class customActionColumn extends ActionColumn
{
/**
* Initializes the default button rendering callbacks.
*/
protected function initDefaultButtons()
{
$this->initDefaultButton('view', 'eye-open', [
'title' => 'Super View',
]);
$this->initDefaultButton('update', 'pencil', [
'title' => 'Super Update',
]);
$this->initDefaultButton('delete', 'trash', [
'data-confirm' => Yii::t('yii', 'Are you sure you want to delete this item?'),
'data-method' => 'post',
'title' => 'Super Delete'
]);
}
/**
* Initializes the default button rendering callback for single button
* #param string $name Button name as it's written in template
* #param string $iconName The part of Bootstrap glyphicon class that makes it unique
* #param array $additionalOptions Array of additional options
* #since 2.0.11
*/
protected function initDefaultButton($name, $iconName, $additionalOptions = [])
{
if (!isset($this->buttons[$name]) && strpos($this->template, '{' . $name . '}') !== false) {
$this->buttons[$name] = function ($url, $model, $key) use ($name, $iconName, $additionalOptions) {
$title = Yii::t('yii', ucfirst($name));
$options = array_merge([
'title' => $title,
'aria-label' => $title,
'data-pjax' => '0',
'title' => 'atata'
], $additionalOptions, $this->buttonOptions);
$icon = Html::tag('span', '', ['class' => "glyphicon glyphicon-$iconName"]);
return Html::a($icon, $url, $options);
};
}
}
}
Now in GridView you just need to specify custom class and that's all.
[
'class' => app\models\customActionColumn::className(),
],

ZF2 - How to add a new Form in an existing Controller?

I have a login Form LoginForm.php with its Filter LoginFilter.php, that has a View /login/index.phtml, a Controller LoginController.php, two Factory LoginControllerFactory.php & LoginFormFactory.php and it is called in the config.module.php and works perfect. The Form is correctly displayed.
I have a ViewController.php that has a method idAction that shows a post by its id passed by parameter from the homepage in a View called /view/id.phtml. I want to display this Form I created within this View and I don't know how. First, I created the Form exactly as I created the login Form, but I realized that I already configured my id child-route, inside of view route with a Factory in module.config.php.
Then, I tried to set the form in the idAction method, exactly as I did in indexAction in LoginController.php Controller, but I'm receiving the following error: An exception was raised while creating "Rxe\Factory\ViewController"; no instance returned.
I will now show you what I did to try to display this new Form.
First, the Form itself:
class CommentForm extends Form
{
public function buildForm()
{
$this->setAttribute('method', 'POST');
$this->setAttribute('id', 'add-comment-form');
$this->add(array(
'name' => 'comment',
'type' => 'textarea',
'options' => array(
'label' => 'Category'
),
'attributes' => array(
'class' => 'form-control'
)
));
$this->add(array(
'name' => 'submit',
'type' => 'submit',
'attributes' => array(
'class' => 'btn btn-success',
'value' => 'Comment'
)
));
}
}
Form's CommentFormFactory.php calling its Filter and building the Form:
class CommentFormFactory implements FactoryInterface
{
public function createService(ServiceLocatorInterface $serviceLocator)
{
$form = new CommentForm();
$form->setInputFilter($serviceLocator->get('Rxe\Factory\CommentFilter'));
$form->buildForm();
return $form;
}
}
The ViewControllerFactory.php calling the CommentFormFactory.php, just like in LoginControllerFactory.php:
class ViewControllerFactory implements FactoryInterface
{
public function createService(ServiceLocatorInterface $serviceLocator)
{
$serviceManager = $serviceLocator->getServiceLocator();
$viewController = new ViewController();
$viewController->setPostsTable($serviceManager->get('Rxe\Factory\PostsTable'));
$viewController->setCommentsTable($serviceManager->get('Rxe\Factory\CommentsTable'));
$viewController->setCommentForm($serviceManager->get('Rxe\Factory\CommentForm'));
return $viewController;
}
}
The ViewController.php, calling the form within its idAction's ViewModel:
class ViewController extends AbstractActionController
{
use PostsTableTrait;
use CommentsTableTrait;
private $commentForm;
function setCommentForm($commentForm)
{
$this->commentForm = $commentForm;
}
public function indexAction()
{
$category = $this->params()->fromRoute('category');
return new ViewModel(array(
'posts' => $this->postsTable->getPostsByCategory($category),
'categories' => $category
));
}
public function idAction()
{
$id = $this->params()->fromRoute('id');
$viewModel = new ViewModel(array(
'commentForm' => $this->commentForm,
'commentParams' => $this->params()->fromPost(),
'messages' => $this->flashMessenger()->getMessages(),
'posts' => $this->postsTable->getPostById($id),
'posts' => $this->commentsTable->getNumberOfCommentsByPost($id),
'comments' => $this->commentsTable->getCommentsByPost($id)
));
$viewModel->setTemplate('rxe/view/id.phtml');
if ($this->getRequest()->isPost()) {
$this->commentForm->setData($this->params()->fromPost());
if ($this->commentForm->isValid()) {
$this->flashMessenger()->addMessage('Thank you for your comment. :)');
} else {
$this->flashMessenger()->addMessage('Your comment wasn\'t sent.');
}
}
return $viewModel;
}
}
And finally my module.config.php
'controllers' => array(
'invokables' => array(
'Rxe\Controller\Index' => 'Rxe\Controller\IndexController',
'Rxe\Controller\View' => 'Rxe\Controller\ViewController',
'Rxe\Controller\Login' => 'Rxe\Controller\LoginController'
),
'factories' => array(
'Rxe\Factory\LoginController' => 'Rxe\Factory\LoginControllerFactory',
'Rxe\Factory\ViewController' => 'Rxe\Factory\ViewControllerFactory',
'Rxe\Factory\IndexController' => 'Rxe\Factory\IndexControllerFactory'
)
),
'service_manager' => array(
'factories' => array(
'Rxe\Factory\LoginForm' => 'Rxe\Factory\LoginFormFactory',
'Rxe\Factory\LoginFilter' => 'Rxe\Factory\LoginFilterFactory',
'Rxe\Factory\CommentForm' => 'Rxe\Factory\CommentFormFactory',
'Rxe\Factory\CommentFilter' => 'Rxe\Factory\CommentFilterFactory',
'Rxe\Factory\PostsTable' => 'Rxe\Factory\PostsTableFactory',
'Rxe\Factory\CategoriesTable' => 'Rxe\Factory\CategoriesTableFactory',
'Rxe\Factory\CommentsTable' => 'Rxe\Factory\CommentsTableFactory',
'Zend\Db\Adapter\AdapterService' => 'Zend\Db\Adapter\AdapterServiceFactory'
)
),
Please, let me know if you need me to show you more codes. Thank you in advance.
EDIT #1
If I remove the line that calls the Form in the ViewControllerFactory.php, I get the following error: Fatal error: Call to a member function prepare() on a non-object in /home/vol12_3/byethost4.com/b4_16354889/htdocs/module/Rxe/view/rxe/view/id.phtml on line 31
The id.phtml is:
<!-- Comment form -->
<div id="comment-form-area" class="col-xs-3">
<?php $this->commentForm->prepare() ?>
<?php echo $this->form()->openTag($this->commentForm); ?>
<div class="form-group comment-area">
<?php echo $this->formRow($this->commentForm->get('comment_content')); ?>
</div>
<div class="form-group">
<?php echo $this->formRow($this->commentForm->get('submit')); ?>
</div>
<?php echo $this->form()->closeTag(); ?>
</div>
<!-- /Comment form -->
Try removing these lines
'invokables' => array(
'Rxe\Controller\Index' => 'Rxe\Controller\IndexController',
'Rxe\Controller\View' => 'Rxe\Controller\ViewController',
'Rxe\Controller\Login' => 'Rxe\Controller\LoginController'
),
If it doesn't work, have a look at this tutorial how to create proper controller factories and pass dependencies. https://samsonasik.wordpress.com/2015/03/31/zend-framework-2-using-__invokepluginmanager-manager-in-services-factory/
An example how I build my forms:
namespace Admin\Form;
use Zend\Form\Form;
use Zend\InputFilter\InputFilterProviderInterface;
class ContentForm extends Form implements InputFilterProviderInterface
{
public function __construct()
{
parent::__construct("content");
}
public function init()
{
$this->setAttribute('method', 'post');
$this->add([
'type' => 'Zend\Form\Element\Text',
'name' => 'title',
'attributes' => [
'required' => true,
'size' => 40,
'id' => "seo-caption",
'placeholder' => 'Title',
],
'options' => [
'label' => 'Title',
],
]);
$this->add([
'type' => 'Zend\Form\Element\Text',
'name' => 'text',
'attributes' => [
'class' => 'ckeditor',
'rows' => 5,
'cols' => 80,
],
'options' => [
'label' => 'Text',
],
]);
}
public function getInputFilterSpecification()
{
return [
[
"name"=>"title",
"required" => true,
'filters' => [
['name' => 'StripTags'],
['name' => 'StringTrim'],
],
'validators' => [
['name' => 'NotEmpty'],
[
'name' => 'StringLength',
'options' => [
'encoding' => 'UTF-8',
'min' => 1,
'max' => 200,
],
],
],
],
[
"name"=>"text",
"required" => true,
'filters' => [
['name' => 'StripTags'],
['name' => 'StringTrim'],
],
'validators' => [
['name' => 'NotEmpty'],
[
'name' => 'StringLength',
'options' => [
'encoding' => 'UTF-8',
'min' => 1,
],
],
],
],
];
}
}
Than I create a Factory
namespace Admin\Factory\Controller;
use Admin\Controller\ContentController;
use Zend\Mvc\Controller\ControllerManager;
class ContentFormFactory
{
/**
* #{inheritDoc}
*/
public function __invoke(ControllerManager $controllerManager)
{
return new ContentController(
$controllerManager->getServiceLocator()->get('FormElementManager')->get('Admin\Form\ContentForm')
);
}
}
Inside module.config.php I have this code
'controllers' => [
'factories' => [
'Admin\Controller\Content' => "Admin\Factory\Controller\ContentFormFactory",
],
'invokables' => [
...
],
],
Please, show us some more code.

ZF2 form with fieldset and doctrine not working

I have a problem with a form, fieldset and doctrine.
This is my edit form. In this form I add the User Fieldset and add another field "password" (that I use only in this form).
EditUserForm:
class EditUserForm extends Form implements InputFilterProviderInterface
{
public function __construct($name = null, $options = [])
{
parent::__construct($name, $options);
$this->setAttribute('method', 'post');
$this->setHydrator(new ClassMethods(false));
$this->setObject(new User());
$this->add([
'name' => 'user',
'type' => 'Application\Form\UserFieldset',
'options' => [
'use_as_base_fieldset' => true
]
]);
$this->add([
'name' => 'password',
'type' => 'Zend\Form\Element\Password',
'attributes' => [
'id' => 'password'
]
]);
}
public function getInputFilterSpecification()
{
return [
'password' => [
'required' => true
],
];
}
}
UserFieldset:
class UserFieldset extends Fieldset implements InputFilterProviderInterface
{
public function __construct($name = null, $options = [])
{
parent::__construct($name, $options);
$this->setHydrator(new ClassMethods(false));
$this->setObject(new User());
$this->add([
'name' => 'name',
'type' => 'Zend\Form\Element\Text',
'attributes' => [
'id' => 'name'
]
]);
$this->add([
'name' => 'surname',
'type' => 'Zend\Form\Element\Text',
'attributes' => [
'id' => 'surname'
]
]);
}
public function getInputFilterSpecification()
{
return [
'name' => [
'required' => true
],
'surname' => [
'required' => true
],
];
}
}
Why if I try to var_dump(form->getData()) does the entity does not have the password field?
object(Application\Entity\User)[114]
private 'name' => string 'john' (length=4)
private 'surname' => string 'smith' (length=5)
private 'password' => null
thanks.
The password needs to be part of the UserFieldset as you're setting the UserFieldset as base-fieldset. If you choose a base-fieldset, only this fieldset will be hydrated recursively.

Not found error in Yii2

I am new to yii2 framework. I have created a controller,model and view. But i am getting not found error(404).
I have create the controller TestController.php, a view create.php and a model Test.php. I have try to run my project in particular controller that time im getting not found error message.
This is my controller page
The controller extends by Controller class. I've using alert boxes in controller page but i hasn't get in any alert.
class TestController extends Controller
{
namespace livefactory\modules\test\controllers;
public function actionCreate()
{
if(!Yii::$app->user->can('Test.Create')){
throw new NotFoundHttpException('You dont have permissions to view this page.');
}
$img = new ImageUpload();
$emailObj = new SendEmail;
$model = new Test;
return $this->render('create', [
'model' => $model,
]);
}
}
My model page
The model page defines all the variables used in the particular controller.
The table name is also defined.
namespace livefactory\models;
class Test extends \yii\db\ActiveRecord
{
/**
* #inheritdoc
*/
public static function tableName()
{
return 'tbl_test';
}
/**
* #inheritdoc
*/
public function rules()
{
return [
[['Name', 'Relationship', 'Age', 'Mail', 'Status'], 'required'],
[['Age'], 'integer'],
[['Name', 'Relationship', 'Mail', 'Status'], 'string', 'max' => 255]
];
}
/**
* #inheritdoc
*/
public function attributeLabels()
{
return [
'id' => Yii::t('app', 'ID'),
'Name' => Yii::t('app', 'Person Name'),
'Relationship' => Yii::t('app', 'Relationship'),
'Age' => Yii::t('app', 'Age'),
'Mail' => Yii::t('app', 'Mail'),
'Status' => Yii::t('app', 'Status'),
}
}
My view page
<?php
use yii\helpers\Html;
use yii\helpers\Html;
use yii\helpers\ArrayHelper;
use kartik\widgets\ActiveForm;
use kartik\builder\Form;
use livefactory\models\Country;
use livefactory\models\State;
use livefactory\models\City;
use kartik\widgets\DepDrop;
use kartik\datecontrol\DateControl;
use livefactory\models\CustomerType;
/**
* #var yii\web\View $this
* #var common\models\Customer $model
*/
$this->title = Yii::t('app', 'Add Person', [
'modelClass' => 'Test',
]);
// $this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Customers'), 'url' => ['index']];
// $this->params['breadcrumbs'][] = $this->title;
?>
<div class="ibox float-e-margins">
<div class="ibox-title">
<h5><?= Html::encode($this->title) ?> <small class="m-l-sm"><?php echo Yii::t ( 'app', 'Enter Person Details' ); ?></small></h5>
<div class="ibox-tools">
<a class="collapse-link">
<i class="fa fa-chevron-up"></i>
</a>
<a class="close-link">
<i class="fa fa-times"></i>
</a>
</div>
</div>
<div class="ibox-content">
<div class="customer-form">
<?php
$form = ActiveForm::begin ( [
'type' => ActiveForm::TYPE_VERTICAL
] );?>
<div class="panel panel-info">
<div class="panel-heading">
<h3 class="panel-title"><?php echo Yii::t ( 'app', 'Person Details' ); ?></h3>
</div>
<div class="panel-body">
<?php
echo Form::widget ( [
'model' => $model,
'form' => $form,
'columns' => 4,
'attributes' => [
'Person Name' => [
'type' => Form::INPUT_TEXT,
'options' => [
'placeholder' => Yii::t ( 'app', 'Enter Person Name' ).'...',
'maxlength' => 255
],
'columnOptions' => [
'colspan' => 3
]
]
,
'Relationship' => [
'type' => Form::INPUT_TEXT,
'options' => [
'placeholder' => Yii::t ( 'app', 'Enter Relationship' ).'...',
'maxlength' => 255
],
'columnOptions' => [
'colspan' => 3
]
]
]
]
);
echo Form::widget ( [
'model' => $model,
'form' => $form,
'columns' => 3,
'attributes' => [
'Age' => [
'type' => Form::INPUT_TEXT,
'options' => [
'placeholder' => Yii::t ( 'app', 'Enter Age' ).'...',
'maxlength' => 255
]
],
'Mail' => [
'type' => Form::INPUT_TEXT,
'options' => [
'placeholder' => Yii::t ( 'app', 'Enter Mail' ).'...',
'maxlength' => 255
]
],
'Status' => [
'type' => Form::INPUT_TEXT,
'options' => [
'placeholder' => Yii::t ( 'app', 'Enter Status' ).'...',
'maxlength' => 255
]
]
]
] );
?>
</div></div>
<?php
// echo Html::submitButton ( $model->isNewRecord ? Yii::t ( 'app', 'Create' ) : Yii::t ( 'app', 'Update' ), [
// 'class' => $model->isNewRecord ? 'btn btn-success customer_submit' : 'btn btn-primary customer_submit'
// ] );
ActiveForm::end ();
?>
</div>
</div>
</div>

Categories