I have attribute and its related attribute values dynamically generated on my view, user can fill and that attribute with values can be saved in table.
<input type="text" name="attribute_name[attr_1]" placeholder="Attribute Name" class="form-control" required="">
<input type="text" name="attribute_value[][attr_1]" placeholder="Attribute Value" class="form-control" required="">
<input type="text" name="attribute_value[][attr_1]" placeholder="Attribute Value" class="form-control" required="">
<input type="text" name="attribute_name[attr_2]" placeholder="Attribute Name" class="form-control" required="">
<input type="text" name="attribute_value[][attr_2]" placeholder="Attribute Value" class="form-control" required="">
<input type="text" name="attribute_value[][attr_2]" placeholder="Attribute Value" class="form-control" required="">
I'm passing here the random key to the attribute name and that same name is passed to attribute values array as a key so that when i get the data through post i can distinguish and relate attribute with there respective attribute values and save it in same row.
One thing to note is the fields are created dynamically and it is not created using loop, but it can be added by clicking on Add button.
now i' getting data using something like this :
foreach($request->attribute_name as $attribute)
{
}
but this i cannot get the attribute and its related values.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire