Laravel: variable as form value - laravel

First Laravel Project.
I want to make an "edit screen" where the "old values" are the predefined default value of the form input field.
I tried this:{{ Form::text('brand', '$product[0]->brand') }}
But I got back
$product[0]->brand
Instead of
Test brand
What I did wrong? What's the good syntax?

Usually, Laravel should reuse the last entry the user used if the form isn't validated as you can read here :
Also, please note that the value will first come from Flash Session Input, only secondly will the value argument be used. This means if your previous request was this form it will automatically display the value the user last entered.
But, if you want, can't you use something like
{{ Form::text('brand', $product[0]->brand) }}
Because you were saying you wanted that specific string by putting ' around your variable.

please use it:
{{Form::text('brand',null,array('class'=>'form-control'))}

Related

Make parameter input required in CloudFormation template

I have a template for AWS Cloud Formation. In this template I have set several parameters.
Now, what I would like to do is to leave a parameter field empty but allow the user to select
a specific parameter for example a security group. Now what I would like to do is that if
a user does not select anything (field stays empty) I want it to give an error message saying
field required when you want to proceed and prevent the user from proceeding, as it happens when you do not enter a stack name (see screenshot below).
How do I do this for any parameter in a cloud formation template??? I have searched around but do not find anything
regarding validation of user input …
I know I could set a default for everything, but I do not want to set a default and specifically force
a user to make a selection in this case …
Please see this thread:
https://forums.aws.amazon.com/thread.jspa?threadID=230829
Suggested solution: simply use regular expressions in AllowedPattern.
For e.g. to have a non blank value:
"AllowedPattern" : ".+"
If you want the parameter to be alpha numeric:
"AllowedPattern" : "[a-zA-Z0-9]+"
To match an exact word:
"AllowedPattern" : "^my_matched_word$"

Laravel validation; human names for array fields

In Laravel form validation you can do this: file_description.* to validate each item of an array according to a set of rules. The problem is, the system automatically returns "file_description.1 is required" as an error message if the field is required and not filled in.
More on that here: https://ericlbarnes.com/2015/04/04/laravel-array-validation/
Now, I'm not a complex man, I just want the field to say "File Description 1 is required". I am aware you can set messages but a) my input arrays are dynamically generated by jquery (click to add more type scenario) so I'd have to use a loop like in the above example b) I feel like there must be a better way.
Is there a way to either extend the core validation system to simply return a humanized name for the array field as Laravel does with regular fields, or is there an option I missed in the docs that allows for this? I'd rather not get involved with doing some regex type search to fix this.

How to recuperate field value in others forms in section template in Orbeon

I have a section Template'Section_library',in 'Section_library' i have a field 'first-name' who recuperate the value field from another section in my form so i used this expression
xxf:component-context()/root()/form/Section_TWO/mycontrol.
this expression not worked totally,the recuperation is done when i try to write in this field 'first-name'. i want a solution that automatically recuperate the value within any interaction of user.
I find this issue #3008 but i didn't understand it.
As of 2016.2, there is no reliable and supported way for code inside a section template to access information about the form it is used in. This is by design, but there are reasonable use cases that call for a section template being able to access things from the "outer form", and you're correct pointing to RFE 3008. For now I'd recommend you follow this issue.

Laravel - Model binding not working when I use accessors

I want to populate my select box from the Laravel IoC Container.
App\Http\Utilities\BillingHelper.php
views/billing/create.blade.php
views/billing/edit.blade.php
Create the table:
Now, instead of the value, i want to display some flags and currency symbols.
Should i use mutators?
Problem
If i use mutators, when i open the edit page, i see always the first value selected, from the BillingHelper, instead of the choosen one.
Any help? Thanks.
I know it should be a comment, but I have no reputation.
What if, on you edit page, you replace null on Form::select with $client->language and $client->currency.
I know that you area binding the values with Form::Model. But worth a try.
When you use mutators the matching won't occur anymore. You'll have to use a matching static array according to the values you'll return. (the flags)
You can make it work if you make a mutator for saving the data also and simplify again to the ['it', 'en', 'lv'], otherwise your saved data will differ and the initial mutator won't work the second time. You can still make a one-time-only test.
This is why:
Your form binding is using $bill->language to retrieve the actual stored data, and compare it with the values in your $bill::lang static array. If no match found, than the first value will be always selected.
Can you provide the the currency and language fields definition in the migration for the bill?
Also retrive your values from your bills DB and paste them here for language and currency. They must be in the defined static sets.
Laravel has a way of skipping the accessor/mutator by using
$model->getOriginal('data_field').
The "getOriginal()" gets the model's original attribute values.

Using url parameters in golang template code

I'm new to Go and trying to modify some code written by someone else. Right now he tests the stored value of a given day to determine if someone took lunch that day or not.
What I want to do is see if there's a stored value and if there isn't, use the default value which is passed via URL parameter. The code looks like this:
<input id="lunch{{.place}}" type="checkbox" {{if index .week.NoMeals .place}} checked {{end}}>
I have a URL variable set like so:
sitename?nolunch=1
So the logic I want is that if the stored data for that day is set, the checkbox will reflect the stored value. If it hasn't been set, the box should be checked if the nolunch URL parameter is set and not checked if it's not.
How do I test for url parameters in Go template code?

Resources