After deploy Magento 2 Translation Extension by Magefan i got following error
{"0":"Warning: class_implements(): Class TranslationGridDataProvider does not exist and could not be loaded in \/home\/419982.cloudwaysapps.com\/vftydjkdjd\/public_html\/vendor\/magento\/framework\/Code\/Reader\/ClassReader.php on line 71","1":"<pre>#1 class_implements('TranslationGridD...') called at [vendor\/magento\/framework\/Code\/Reader\/ClassReader.php:71]\n#2 Magento\\Framework\\Code\\Reader\\ClassReader->getParents('TranslationGridD...') called at [vendor\/magento\/framework\/View\/Element\/UiComponent\/Argument\/Interpreter\/ConfigurableObject.php:118]\n#3 Magento\\Framework\\View\\Element\\UiComponent\\Argument\\Interpreter\\ConfigurableObject->getParents('TranslationGridD...') called at [vendor\/magento\/framework\/View\/Element\/UiComponent\/Argument\/Interpreter\/ConfigurableObject.php:96]\n#4 Magento\\Framework\\View\\Element\\UiComponent\\Argument\\Interpreter\\ConfigurableObject->evaluate(array('name' => 'dataProvider', 'argument' => array('class' => array('name' => 'class', 'xsi:type' => 'string', 'value' => 'TranslationGridD...'), 'name' => array('name' => 'name', 'xsi:type' => 'string', 'value' => 'translation_tran...'), 'primaryFieldName' => array('name' => 'primaryFieldName', 'xsi:type' => 'string', 'value' => 'key_id'), 'requestFieldName' => array('name' => 'requestFieldName', 'xsi:type' => 'string', 'value' => 'id'), 'data' => array('name' => 'data', 'xsi:type' => 'array', 'item' => array('config' => array('name' => 'config', 'xsi:type' => 'array', 'item' => array('component' => array('name' => 'component', 'xsi:type' => 'string', 'value' => 'Magento_Ui\/js\/gr...'), 'update_url' => array('name' => 'update_url', 'xsi:type' => 'url', 'path' => 'mui\/index\/render'), 'storageConfig' => array('name' => 'storageConfig', 'xsi:type' => 'array', 'item' => array('indexField' => array('name' => 'indexField', 'xsi:type' => 'string', 'value' => 'key_id')))))))))) called at [generated\/code\/Magento\/Framework\/Data\/Argument\/InterpreterInterface\/Proxy.php:95]\n#5 Magento\\Framework\\Data\\Argument\\InterpreterInterface\\Proxy->evaluate(array('name' => 'dataProvider', 'argument' => array('class' => array('name' => 'class', 'xsi:type' => 'string', 'value' => 'TranslationGridD...'), 'name' => array('name' => 'name', 'xsi:type' => 'string', 'value' => 'translation_tran...'), 'primaryFieldName' => array('name' => 'primaryFieldName', 'xsi:type' => 'string', 'value' => 'key_id'), 'requestFieldName' => array('name' => 'requestFieldName', 'xsi:type' => 'string', 'value' => 'id'), 'data' => array('name' => 'data', 'xsi:type' => 'array', 'item' => array('config' => array('name' => 'config', 'xsi:type' => 'array', 'item' => array('component' => array('name' => 'component', 'xsi:type' => 'string', 'value' => 'Magento_Ui\/js\/gr...'), 'update_url' => array('name' => 'update_url', 'xsi:type' => 'url', 'path' => 'mui\/index\/render'), 'storageConfig' => array('name' => 'storageConfig', 'xsi:type' => 'array', 'item' => array('indexField' => array('name' => 'indexField', 'xsi:type' => 'string', 'value' => 'key_id')))))))))) called at [vendor\/magento\/framework\/Data\/Argument\/Interpreter\/Composite.php:61]\n#6 Magento\\Framework\\Data\\Argument\\Interpreter\\Composite->evaluate(array('name' => 'dataProvider', 'argument' => array('class' => array('name' => 'class', 'xsi:type' => 'string', 'value' => 'TranslationGridD...'), 'name' => array('name' => 'name', 'xsi:type' => 'string', 'value' => 'translation_tran...'), 'primaryFieldName' => array('name' => 'primaryFieldName', 'xsi:type' => 'string', 'value' => 'key_id'), 'requestFieldName' => array('name' => 'requestFieldName', 'xsi:type' => 'string', 'value' => 'id'), 'data' => array('name' => 'data', 'xsi:type' => 'array', 'item' => array('config' => array('name' => 'config', 'xsi:type' => 'array', 'item' => array('component' => array('name' => 'component', 'xsi:type' => 'string', 'value' => 'Magento_Ui\/js\/gr...'), 'update_url' => array('name' => 'update_url', 'xsi:type' => 'url', 'path' => 'mui\/index\/render'), 'storageConfig' => array('name' => 'storageConfig', 'xsi:type' => 'array', 'item' => array('indexField' => array('name' => 'indexField', 'xsi:type' => 'string', 'value' => 'key_id')))))))))) called at [vendor\/magento\/module-ui\/Config\/Data.php:164]\n#7 Magento\\Ui\\Config\\Data-
Please make sure that when installing Magento 2 Translation Extension you followed the installation instructions, especially the step
php bin/magento setup:di:compile
This is contact form and sorking.
I would like to switch email destination by User selecting check box.
For example. Here is a column called genders.
When user check 'man' select box, email destination will be [TO]'man_survey#12345677.site' and [CC] is 'man_cc_survey#12345677.site'.
When user check 'female', email destination will be [TO] 'female_survey#12345677.site' and [CC] is 'female_cc_survey#12345677.site'
Could you teach me how to add this function to my current code?
My Laravel framework is 5.7.28
public function complete(ContactRequest $request)
{
$input = $request->except('action');
if ($request->action === 'back') {
return redirect()->action('ContactsController#index')->withInput($input); }
if (isset($request->type)) {
$request->merge(['type' => implode(', ', $request->type)]);
}
// store data
Contact::create($request->all());
// send mail
\Mail::send(new \App\Mail\Contact([
'to' => $request->email,
'to_name' => $request->name,
'from' => 'survey#12345677.site',
'from_name' => 'from name',
'subject' => 'Thank you',
'type' => $request->type,
'gender' => $request->gender,
'body' => $request->body
]));
// recive mail
\Mail::send(new \App\Mail\Contact([
'to' => 'survey#12345677.site',
'to_name' => 'to name',
'from' => $request->email,
'from_name' => $request->name,
'subject' => 'you got mail',
'type' => $request->type,
'gender' => $request->gender,
'body' => $request->body
], 'from'));
return view('contacts.complete');
}
}
UPDATE THis worked
public function complete(ContactRequest $request)
{
$input = $request->except('action');
if ($request->action === 'back') {
return redirect()->action('ContactsController#index')->withInput($input); }
if (isset($request->type)) {
$request->merge(['type' => implode(', ', $request->type)]);
}
// store data
Contact::create($request->all());
if($request->gender == 'male') {
// send mail
\Mail::send(new \App\Mail\Contact([
'to' => $request->email,
'to_name' => $request->name,
'from' => 'man_survey#12345677.site',
'from_name' => 'from name',
'subject' => 'Thank you',
'type' => $request->type,
'gender' => $request->gender,
'body' => $request->body
]));
// recive mail
\Mail::send(new \App\Mail\Contact([
'to' => $email,
'to_name' => 'to name',
'from' => $request->email,
'from_name' => $request->name,
'subject' => 'you got mail',
'type' => $request->type,
'gender' => $request->gender,
'body' => $request->body
], 'from'));
return view('contacts.complete');
} else {
// send mail
\Mail::send(new \App\Mail\Contact([
'to' => $request->email,
'to_name' => $request->name,
'from' => 'female_survey#12345677.site',
'from_name' => 'from name',
'subject' => 'Thank you',
'type' => $request->type,
'gender' => $request->gender,
'body' => $request->body
]));
// recive mail
\Mail::send(new \App\Mail\Contact([
'to' => $email,
'to_name' => 'to name',
'from' => $request->email,
'from_name' => $request->name,
'subject' => 'you got mail',
'type' => $request->type,
'gender' => $request->gender,
'body' => $request->body
], 'from'));
return view('contacts.complete');
}
}
You can use a radio button in the form to see what Gender the user has selected.
In HTML
<input type="radio" name="gender" value="male">Male
<input type="radio" name="gender" value="female">Female
<input type="radio" name="gender" value="no_answer">Prefer Not to Answer
In the controller you can use something like this
public function complete(ContactRequest $request)
{
$input = $request->except('action');
if ($request->action === 'back') {
return redirect()->action('ContactsController#index')->withInput($input); }
if (isset($request->type)) {
$request->merge(['type' => implode(', ', $request->type)]);
}
// store data
Contact::create($request->all());
if($request->gender == 'male') {
$email = 'man_survey#12345677.site';
$cc_email = 'man_cc_survey#12345677.site'
} else {
$email = 'female_survey#12345677.site';
$cc_email = 'female_cc_survey#12345677.site'
}
// send mail
\Mail::send(new \App\Mail\Contact([
'to' => $request->email,
'to_name' => $request->name,
'from' => 'survey#12345677.site',
'from_name' => 'from name',
'subject' => 'Thank you',
'type' => $request->type,
'gender' => $request->gender,
'body' => $request->body
]));
// recive mail
\Mail::send(new \App\Mail\Contact([
'to' => $email,
'to_name' => 'to name',
'from' => $request->email,
'from_name' => $request->name,
'subject' => 'you got mail',
'type' => $request->type,
'gender' => $request->gender,
'body' => $request->body
], 'from'));
return view('contacts.complete');
}
This question already has answers here:
How do I style the HTML form validation error messages with CSS?
(4 answers)
Closed 3 years ago.
I modified the code like this: ArticleRequest.php
public function rules()
{
return [
'title' => 'required|min:2|max:255',
'slug' => 'unique:articles,slug,'.\Request::get('id'),
'content' => 'required|min:2',
'date' => 'required|date',
'status' => 'required',
'category_id' => 'required',
'description'=> 'required',
];
}
ArticleCrudController.php
$this->crud->addField([
'name' => 'description',
'label' => 'Description',
'type' => 'text',
'placeholder' => 'Description meta tag',
'attributes' => [
'required' => true,
],
]);
Why is the style different? something is missing?
thanks, you are very kind
Marco
public function rules()
{
return [
'title' => 'required|min:2|max:255',
// you should add validation rule for description attr
'description' => 'required',
'slug' => 'unique:articles,slug,'.\Request::get('id'),
'content' => 'required|min:2',
'date' => 'required|date',
'status' => 'required',
'category_id' => 'required',
'description'=> 'required',
];
}
I have a web application that is using Laravel with the Backpack addon.
Recently i discovered this problem where some fields in the create / edit route in a controller are not selectable in mobile (as if they were readonly). This only happens in mobile (in all browsers) and on this specific controller.
I should also specify that the fields that don't work don't have a reandonly 'style' (darker, grey text). they seem normal, i can't just select them (click on them).
This is part of the form, the fields in the red box are the one that work, the ones outside do not work.
Here is the code in the setup function of the controller:
public function setup()
{
//if (!backpack_user()->hasRole('administrator'))
// abort(403);
/*
|--------------------------------------------------------------------------
| CrudPanel Basic Information
|--------------------------------------------------------------------------
*/
$this->crud->setModel('App\Models\Travel');
$this->crud->setRoute(config('backpack.base.route_prefix') . '/travel');
$this->crud->setEntityNameStrings('travel', 'travels');
$this->crud->setListView('backpack::crud.travel2');
$this->crud->filters();
/*
|--------------------------------------------------------------------------
| CrudPanel Configuration
|--------------------------------------------------------------------------
*/
if ((backpack_user()->hasRole('administrator'))||(backpack_user()->hasRole('superuser'))) //se utente è admin
{
$this->crud->addClause('where','user_id',backpack_user()->id);
// TODO: remove setFromDb() and manually define Fields and Columns
$this->crud->setFromDb();
// add asterisk for fields that are required in TravelRequest
$this->crud->setRequiredFields(StoreRequest::class, 'create');
$this->crud->setRequiredFields(UpdateRequest::class, 'edit');
$this->crud->allowAccess('show');
$this->crud->enableExportButtons();
$this->crud->orderBy('date_start','DESC');
$this->crud->removeColumn('calendar_header');
$this->crud->modifyField('user_id',[
'name' => 'user_id',
'type' => 'hidden',
'value' => backpack_user()->id,
]);
$this->crud->modifyField('calendar_header', [
'name' => 'calendar_header',
'label' => "Intestazione Calendario",
'type' => 'text'
]);
$this->crud->modifyField('client_id', [ // Select2
'label' => "Cliente",
'type' => 'select2',
'name' => 'client_id',
'entity' => 'client',
'attribute' => 'businessname',
'model' => "App\Models\Client",
'placeholder' => 'Seleziona un Cliente',
'options' => (function ($query) {
return $query->orderBy('id', 'ASC')->where('user_id', backpack_user()->id)->get();
}),
]);
$this->crud->modifyField('date_start', [
'name' => 'date_start',
'type' => 'datetime',
'label' => 'Data-Ora di Inizio',
'default' => date("Y-m-d H:i:s"),
'attributes' => [
'required'=>'required',
],
// optional:
/*'datetime_picker_options' => [
'format' => 'DD/MM/YYYY HH:mm',
'language' => 'it'
],*/
]);
$this->crud->modifyField('departure', [
'name' => 'departure', // the db column name (attribute name)
'label' => "Luogo di Partenza", // the human-readable label for it
'type' => 'text' // the kind of column to show
]);
$this->crud->modifyField('destination', [
'name' => 'destination', // the db column name (attribute name)
'label' => "Luogo di destinazione", // the human-readable label for it
'type' => 'text' // the kind of column to show
]);
$this->crud->modifyField('passenger', [
'name' => 'passenger', // the db column name (attribute name)
'label' => "Passeggero", // the human-readable label for it
'type' => 'text' // the kind of column to show
]);
$this->crud->modifyField('passenger_number', [
'name' => 'passenger_number', // the db column name (attribute name)
'label' => "N° di Passeggeri", // the human-readable label for it
'type' => 'number', // the kind of column to show
'attributes' => ["step" => "any"],
]);
$this->crud->modifyField('payment_type', [ // select_from_array
'name' => 'payment_type',
'label' => "Tipo Pagamento",
'type' => 'select_from_array',
'options' => ['Fattura' => 'Fattura', 'Carta Di Credito' => 'Carta Di Credito', 'Contanti' => 'Contanti', 'Carte di credito da remoto' => 'Carte di credito da remoto', 'Conto' => 'Conto', 'Paypal' => 'Paypal'],
'allows_null' => true,
'default' => 'one',
// 'allows_multiple' => true, // OPTIONAL; needs you to cast this to array in your model;
]);
$this->crud->modifyField('dare', [
'name' => 'dare', // the db column name (attribute name)
'label' => "Dare €", // the human-readable label for it
'type' => 'number', // the kind of column to show
'attributes' => ["step" => "any"],
]);
$this->crud->modifyField('avere', [
'name' => 'avere', // the db column name (attribute name)
'label' => "Avere €", // the human-readable label for it
'type' => 'number', // the kind of column to show
'attributes' => ["step" => "any"],
]);
$this->crud->modifyField('driver_id', [ // Select2
'label' => "Autista",
'type' => 'select2',
'attributes' => [
'required'=>'required',
],
'name' => 'driver_id', // the db column for the foreign key
'entity' => 'driver', // the method that defines the relationship in your Model
'attribute' => 'businessname', // foreign key attribute that is shown to user
'model' => "App\Models\Driver", // foreign key model
'placeholder' => 'Seleziona un Autista', // placeholder for the select
'options' => (function ($query) {
return $query->orderBy('id', 'ASC')->where('user_id', backpack_user()->id)->get();
}),
]);
$this->crud->modifyField('car_id', [ // Select2
'label' => "Mezzo",
'type' => 'select2',
'name' => 'car_id', // the db column for the foreign key
'entity' => 'car', // the method that defines the relationship in your Model
'attribute' => 'fullcar', // foreign key attribute that is shown to user
'model' => "App\Models\Car", // foreign key model
'placeholder' => 'Seleziona un Mezzo', // placeholder for the select
'options' => (function ($query) {
return $query->orderBy('id', 'ASC')->where('user_id', backpack_user()->id)->get();
}),
]);
$this->crud->modifyField('service_id', [ // Select2
'label' => "Servizio",
'type' => 'select2',
'name' => 'service_id', // the db column for the foreign key
'entity' => 'service', // the method that defines the relationship in your Model
'attribute' => 'type', // foreign key attribute that is shown to user
'model' => "App\Models\Service", // foreign key model
'placeholder' => 'Seleziona un Servizio', // placeholder for the select
'options' => (function ($query) {
return $query->orderBy('id', 'ASC')->where('user_id', backpack_user()->id)->get();
}),
]);
$this->crud->modifyField('category_id', [ // Select2
'label' => "Tipo Mezzo",
'type' => 'select2',
'name' => 'category_id', // the db column for the foreign key
'entity' => 'category', // the method that defines the relationship in your Model
'attribute' => 'name', // foreign key attribute that is shown to user
'model' => "App\Models\Category", // foreign key model
'placeholder' => 'Seleziona una Categoria', // placeholder for the select
'options' => (function ($query) {
return $query->orderBy('id', 'ASC')->where('user_id', backpack_user()->id)->get();
}),
]);
$this->crud->modifyField('general_notes', [
'name' => 'general_notes', // the db column name (attribute name)
'label' => "Note Generali", // the human-readable label for it
'type' => 'textarea' // the kind of column to show
]);
$this->crud->modifyField('state_booked', [ // Checkbox
'name' => 'state_booked',
'label' => 'Prenotato',
'type' => 'checkbox'
]);
$this->crud->modifyField('state_inprogress', [ // Checkbox
'name' => 'state_inprogress',
'label' => 'In Corso',
'type' => 'checkbox'
]);
$this->crud->modifyField('state_ended', [ // Checkbox
'name' => 'state_ended',
'label' => 'Concluso',
'type' => 'checkbox'
]);
$this->crud->modifyField('state_canceled', [ // Checkbox
'name' => 'state_canceled',
'label' => 'Annullato',
'type' => 'checkbox'
]);
$this->crud->modifyField('state_receipt', [ // Checkbox
'name' => 'state_receipt',
'label' => 'Ricevuta',
'type' => 'checkbox'
]);
$this->crud->modifyField('state_creditcard', [ // Checkbox
'name' => 'state_creditcard',
'label' => 'Carta Di Credito',
'type' => 'checkbox'
]);
$this->crud->modifyField('state_cash', [ // Checkbox
'name' => 'state_cash',
'label' => 'Contanti',
'type' => 'checkbox'
]);
$this->crud->modifyField('state_confirmed', [ // Checkbox
'name' => 'state_confirmed',
'label' => 'Confermato',
'type' => 'checkbox'
]);
$this->crud->modifyField('state_to_confirm', [ // Checkbox
'name' => 'state_to_confirm',
'label' => 'Da Confermare',
'type' => 'checkbox'
]);
$this->crud->modifyField('state_shared', [ // Checkbox
'name' => 'state_shared',
'label' => 'Condiviso',
'type' => 'checkbox'
]);
$this->crud->modifyField('passenger_phonenumber', [
'name' => 'passenger_phonenumber', // the db column name (attribute name)
'label' => "Numero di Telefono Passeggero", // the human-readable label for it
'type' => 'text' // the kind of column to show
]);
$this->crud->modifyField('flight_number', [
'name' => 'flight_number', // the db column name (attribute name)
'label' => "Ind. Volo", // the human-readable label for it
'type' => 'text' // the kind of column to show
]);
$this->crud->modifyField('amount_taxable', [
'name' => 'amount_taxable', // the db column name (attribute name)
'label' => "Imponibile €", // the human-readable label for it
'type' => 'amount_senzaiva', // the kind of column to show
'attributes' => ["step" => "any"]
]);
$this->crud->modifyField('amount', [
'name' => 'amount', // the db column name (attribute name)
'label' => "Importo €", // the human-readable label for it
'type' => 'amount_coniva', // the kind of column to show
'attributes' => ["step" => "any"],
]);
$this->crud->modifyField('discount_number', [
'name' => 'discount_number', // the db column name (attribute name)
'label' => "sconto (€)", // the human-readable label for it
'type' => 'number', // the kind of column to show
'attributes' => ["step" => "any"],
]);
$this->crud->modifyField('discount_percent', [
'name' => 'discount_percent', // the db column name (attribute name)
'label' => "sconto (%)", // the human-readable label for it
'type' => 'number', // the kind of column to show
'attributes' => ["step" => "any"],
]);
$this->crud->modifyField('amount_final', [
'name' => 'amount_final', // the db column name (attribute name)
'label' => "Importo Scontato", // the human-readable label for it
'type' => 'amount_final', // the kind of column to show
'attributes' => ["step" => "any"],
]);
$this->crud->modifyField('amount_cash', [
'name' => 'amount_cash', // the db column name (attribute name)
'label' => "Importo Pagamento Diretto", // the human-readable label for it
'type' => 'number', // the kind of column to show
'attributes' => ["step" => "any"],
]);
$this->crud->modifyField('end_date', [ // date_picker
'name' => 'end_date',
'type' => 'datetime',
'label' => 'Data-Ora di Fine',
'default' => date("Y-m-d H:i:s"),
// optional:
/*'datetime_picker_options' => [
'format' => 'DD/MM/YYYY HH:mm',
'language' => 'it'
],*/
]);
$this->crud->modifyField('km', [
'name' => 'km', // the db column name (attribute name)
'label' => "Kilometri", // the human-readable label for it
'type' => 'number', // the kind of column to show
'attributes' => ["step" => "any"],
]);
$this->crud->modifyField('kmdeparture', [
'name' => 'kmdeparture', // the db column name (attribute name)
'label' => "Kilometri Partenza", // the human-readable label for it
'type' => 'number', // the kind of column to show
'attributes' => ["step" => "any"],
]);
$this->crud->modifyField('kmarrival', [
'name' => 'kmarrival', // the db column name (attribute name)
'label' => "Kilometri Arrivo", // the human-readable label for it
'type' => 'number', // the kind of column to show
'attributes' => ["step" => "any"],
]);
$this->crud->modifyField('hours', [
'name' => 'hours', // the db column name (attribute name)
'label' => "Ore Totali", // the human-readable label for it
'type' => 'number', // the kind of column to show
'attributes' => ["step" => "any"],
]);
$this->crud->modifyField('waiting_hours', [
'name' => 'waiting_hours', // the db column name (attribute name)
'label' => "Ore Totali di attesa", // the human-readable label for it
'type' => 'number', // the kind of column to show
'attributes' => ["step" => "any"],
]);
$this->crud->modifyField('report_notes', [
'name' => 'report_notes', // the db column name (attribute name)
'label' => "Note sul Report", // the human-readable label for it
'type' => 'textarea' // the kind of column to show
]);
$this->crud->modifyField('invoice_description', [
'name' => 'invoice_description', // the db column name (attribute name)
'label' => "Descrizione Fattura", // the human-readable label for it
'type' => 'textarea' // the kind of column to show
]);
$this->crud->modifyField('sign', [ // image
'label' => "Immagine Cartello",
'name' => "sign",
'type' => 'image',
'upload' => true,
'disk' => 'public'
]);
//***********************************************************
//Rimuovo le colonne che non servono
$this->crud->removeColumn('amount_final');
$this->crud->removeColumn('discount_number');
$this->crud->removeColumn('discount_percent');
$this->crud->removeColumn('km');
$this->crud->removeColumn('hours');
$this->crud->removeField('amount_final');
$this->crud->removeField('discount_number');
$this->crud->removeField('discount_percent');
$this->crud->removeField('km');
$this->crud->removeField('hours');
//***********************************************************
$this->crud->addButtonFromModelFunction('line', 'send_mail', 'sendMail', 'beginning');
$this->crud->addButtonFromModelFunction('line', 'print_doc', 'printDoc', 'beginning');
}
elseif (backpack_user()->hasRole('base')) { //se utente è base
$this->crud->denyAccess(['list', 'create', 'delete']);
$this->crud->setRequiredFields(UpdateRequest::class, 'edit');
$this->crud->addField([
'name' => 'kmdeparture', // the db column name (attribute name)
'label' => "Kilometri alla partenza", // the human-readable label for it
'type' => 'text' // the kind of column to show
],'kmdeparture');
$this->crud->addField([
'name' => 'kmarrival', // the db column name (attribute name)
'label' => "Kilomertri all'arrivo", // the human-readable label for it
'type' => 'text' // the kind of column to show
],'kmarrival');
$this->crud->addField([ // Checkbox
'name' => 'state_canceled',
'label' => 'Annullato',
'type' => 'checkbox'
]);
$this->crud->addField([ // Checkbox
'name' => 'state_confirmed',
'label' => 'Confermato',
'type' => 'checkbox'
]);
$this->crud->addField([ // Checkbox
'name' => 'state_to_confirm',
'label' => 'Da Confermare',
'type' => 'checkbox'
]);
$this->crud->addField([ // date_picker
'name' => 'end_date',
'type' => 'datetime',
'label' => 'Data-Ora di Fine',
'default' => date("Y-m-d H:i:s"),
// optional:
/*'datetime_picker_options' => [
'format' => 'DD/MM/YYYY HH:mm',
'language' => 'it'
],*/
]);
$this->crud->addField([
'name' => 'waiting_hours', // the db column name (attribute name)
'label' => "Ore Totali di attesa", // the human-readable label for it
'type' => 'number', // the kind of column to show
'attributes' => ["step" => "any"],
]);
$this->crud->addField([
'name' => 'report_notes', // the db column name (attribute name)
'label' => "Note sul Report", // the human-readable label for it
'type' => 'textarea' // the kind of column to show
]);
}
}
I already tried removing $this->crud->setFromDb(); and set the columns and fields manually with $this->crud->addColumn and $this->crud->addField but nothing changes.
I am pretty new to backpack and outside that i don't really know what to do.
I am using backpack 3.5 and laravel 5.7.26
**note that i omitted all the modifyColumn from the code
!!! IMPORTANT UPDATE
I tried to comment out random portions of code and apparently is the:
this->crud->modifyField('sign', [ // image
'label' => "Immagine Cartello",
'name' => "sign",
'type' => 'image',
'upload' => true,
'disk' => 'public'
]);
that causes the problem, still i don't understand the reason
in laravel validation (registering) i want to compare one of the fields with a php variable (it should be equal with that)
how can i do this?
protected function validator(array $data)
{
return Validator::make($data, [
'name' => 'required|max:255',
'phone' => 'required|min:10|max:11|unique:users',
'email' => 'required|email|max:255',
'password' => 'required',
'password_confirmation' => 'required',
'user_captcha' => 'required'
]);
}
You can do it for example for name field like this:
$variable = "something"
return Validator::make($data, [
'name' => [
'required',
Rule::in([$variable]),
],
'phone' => 'required|min:10|max:11|unique:users',
'email' => 'required|email|max:255',
'password' => 'required',
'password_confirmation' => 'required',
'user_captcha' => 'required'
]);
Remember to import Rule Class (use Illuminate\Validation\Rule;)
You can get more info in: https://laravel.com/docs/5.4/validation#rule-in
EDIT
As suggested by #patricus, you can also concatenate the variable
$variable = "something"
return Validator::make($data, [
'name' => 'required|in:'.$variable,
'phone' => 'required|min:10|max:11|unique:users',
'email' => 'required|email|max:255',
'password' => 'required',
'password_confirmation' => 'required',
'user_captcha' => 'required'
]);
EDIT2
If you have a variable that is an array:
$variable = ['one','two'];
return Validator::make($data, [
'name' => 'required|in:'.implode(",", $variable),
'phone' => 'required|min:10|max:11|unique:users',
'email' => 'required|email|max:255',
'password' => 'required',
'password_confirmation' => 'required',
'user_captcha' => 'required'
]);
Or
$variable = ['one','two']
return Validator::make($data, [
'name' => [
'required',
Rule::in($variable),
],
'phone' => 'required|min:10|max:11|unique:users',
'email' => 'required|email|max:255',
'password' => 'required',
'password_confirmation' => 'required',
'user_captcha' => 'required'
]);