This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

Wouter
Wouter

Hi,

I have created a backend form for a plugin. But I did not use the yaml because I need other elements names for a ajax script. So I tought when I click the submit button I can call a ajax function to insert everything in the db. But I can't access the form values. In the docs I read that I have to use:

 Request::input('field_name'); 

But when I try to insert the fieldname in the database I see that everything is empty.

How can I use my own created form with my own fieldnames ? Do I have to create a backend component ?

Scott
Scott

What do you mean you didn't use yaml because you needed other element names? Just specify your field names as the key values.

field_name:
    label: Field name

some_other_name:
    label: Some other field
    type: dropdown
    options:
        some_option: Some option
        some_other_option: Some other option
Wouter
Wouter

What is have done is created a form by myself with html in create.htm.

https://jsfiddle.net/c5hr376n/ (I don't know hot to place html here)

I expected that I can with Request :: input ('field_name'); in de db query can save to info in the db.

Last updated

Scott
Scott

Yikes, this is not how you want to make backend forms. I highly suggest reading the documentation and looking at the source code of other plugins. There are also many helpful screencasts and tutorials, just check the resources page.

The basic way you should be doing this, is through your model's fields.yaml file. This file lets you set up a form however you need. If you need more than just your basic input types, you can create a form widget to do whatever you need.

Wouter
Wouter

I was all ready thinking that I do it wrong but not getting it clear when I have to create a widget or component for a backend form. So that's why I started with the above....

Thanks to point me the right way! I would try to see what I can do with the fields.yaml and a form widget... I will read again everything and hope I get figure out how I can fix the names of the input field so my ajax script will still work.

Last updated

1-5 of 5

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.