0

I'm trying to replicate this logic:

insert multiple fields using foreach loop - using laravel 4 and blade.

I tried this:

<div>
    {{ Form::select('linkType[]', array('Facebook', 'Twitter','Other')) }}
    {{ Form::text('linkUrl[]') }}<br>
    {{ Form::select('linkType[]', array('Facebook', 'Twitter','Other')) }}
    {{ Form::text('linkUrl[]') }}
    ...
</div>

But that gives me this laravel error:

ErrorException (E_UNKNOWN) htmlentities() expects parameter 1 to be string, array given (view:...)

Any idea how to fix that? Thanks


Update

A few of these works: {{ Form::text('linkurl[]') }} So that is written as it should.
A few of this also works:

<select name="linktype[]"/>
    <option value="facebook">Facebook</option>
    <option value="twitter">Twitter</option>
</select>

So the problem is 99% sure in the:

{{ Form::select('linkType[]', array('Facebook', 'Twitter','Other')) }}

What I'm I doing wrong?

2
  • Which exact Laravel version are you using? Can you post the full stack trace and preferable your entire view where you're creating the form? Commented Nov 1, 2014 at 14:56
  • Laravel 4 homestead - I have no idea how, but after a few hours of testing and commenting lines away while testing it suddenly started worked with the code from the opening post. The only thing that changed was a lable that I removed... I will answer my question and post my full code as edu material. Commented Nov 1, 2014 at 16:04

1 Answer 1

0

Works for me...

<!doctype html>
<html lang="en">
<body>
    <div>
        {{ Form::select('linkType[]', ['Facebook', 'Twitter','Other']) }}
    </div>
</body>
</html>

generates:

enter image description here

Sign up to request clarification or add additional context in comments.

1 Comment

As commented under the opening post. After hours of trying to debug the original code started working. (I did remove the label for the select.) But I just found out ->withInput() was killing it, it cannot give back an input[] array. And as I think I had set my label for "linkType[]" that might have been the problem. Solution was to set withInput(Input::except('linkUrl','linkType')) so it does not give back the links the user submitted. Will answer fully and type out findings later this week.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.