Code Monkey home page Code Monkey logo

Comments (8)

kristijanhusak avatar kristijanhusak commented on May 27, 2024

What you mean result is empty page? Do you get any error?

What is returned by $existTranslates ?

Also, addData does not bind values to the fields, it just passes the data to the form class so you can use it inside like this:

<?php 
class TestForm extends Form {
    public function buildForm()
    {
        $this->add('name', 'text', [
            'default_value' => $this->getData('foo') // 'bar'
       ]);
    }
}

from laravel-form-builder.

jaroslawziolkowski avatar jaroslawziolkowski commented on May 27, 2024

@kristijanhusak

$existTranslates;
$row->key; // eg bar

is Eloquent ORM object with data (8 records)
I mean that

form($form) 

in view.
result is empty without errors.

What method should I use to bind data in controller?

from laravel-form-builder.

kristijanhusak avatar kristijanhusak commented on May 27, 2024

I'm really not sure why you get no errors, try debugging.

I just updated to version 1.3 which allows Collection type. I would suggest using that.

If you want to stick with your solution, you can bind data this way:

<?php
<?php
if ($existTranslates->count()>0) {
    foreach($existTranslates->get() as $row) {
        $form->add($row->key, 'text', [
            'label'=>$row->key,
            'default_value' => $row->value // Not sure what is value on the $row
            'wrapper'=>['class'=>'large-4']
        ]);
    }
}

from laravel-form-builder.

jaroslawziolkowski avatar jaroslawziolkowski commented on May 27, 2024

@kristijanhusak
Thanks for update.
I updated to 1.3.

It works fine. But my problem was not in version. In my array was duplicate value for "name" attribute.

BTW, How can I debug similar situation? Because FormBuilder not throw warning, only not show form.

from laravel-form-builder.

kristijanhusak avatar kristijanhusak commented on May 27, 2024

Well, maybe try dumping complete form in the view with dd($form) and see what happens.
It should throw this exception when you try to add field with same name. Really strange it didn't throw it. I'll test it and let you know.

from laravel-form-builder.

kristijanhusak avatar kristijanhusak commented on May 27, 2024

I tested it, and i get the exception that should occur as i wrote above.
I added additional checks to the latest version, do a composer update. If it does not update anything, just clear cache like this : rm -rf ~/.composer/cache/kris, remove vendors folder and do a composer update. Hope this helps.

from laravel-form-builder.

jaroslawziolkowski avatar jaroslawziolkowski commented on May 27, 2024

Ok I see this errors. Thank you for help.

from laravel-form-builder.

kristijanhusak avatar kristijanhusak commented on May 27, 2024

No problem :)

from laravel-form-builder.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.