Topic on Extension talk:Semantic Forms Inputs

Tiny tutorial for programming SFI?

4
Katkov Yury (talkcontribs)

Hi Stephan and all the developers! Would you mind to write sometime a tiny manual on how to program new Form Input?

F.trott (talkcontribs)

Hi Yury, a very short manual would probably be something like 1. Create a subclass of SFFormInput, e.g. call it MyNewInputClass 2. Register your new input like this: $sfgFormPrinter->registerInputType( 'MyNewInputClass' );

There are a few things to be aware of (e.g. the expected name attribute of the html input elements), but this is the basic idea. I think the SFI code improved a lot lately, so it should be possible to follow what is done there. E.g. have a look at the timepicker code. And if you come up with an input, that could be useful for others, consider contributing it!

Cheers,

Katkov Yury (talkcontribs)

I have almost finished with my FormsInput for picking multiple elements so I'll be able to expand your instructions a little bit. I still don't understand some things, would you mind to help me with them?

  • the name attribute of the form input sometimes have brackets like in it like this: input3[].
  • On the other hand sometimes we add an additional hidden element like
    Html::hidden($name . '[is_list]', 1)
    
    .
  • And thirdly we have the method canHandleLists() to override.

It seems that all three thing are indicating that the form input can handle lists, but it's pretty weird to see three different pieces of code trying to say the same thing. :-)

F.trott (talkcontribs)

Sorry, I never developed any inputs capable of handling lists. You should contact Yaron about that. Cheers,

Reply to "Tiny tutorial for programming SFI?"