greg_808

^^^ I don’t know if you can use that module in the frontend, I usualy use that for cms form fields, and I’d write the js part myselfe.

sdoh

heh, just found this - https://github.com/unclecheese/silverstripe-display-logic - i think this is what I need

Show 1 attachment(s)
GitHub  
unclecheese/silverstripe-display-logic

The Display Logic module allows you to add conditions for displaying or hiding certain form fields based on client-side behavior. - unclecheese/silverstripe-display-logic

Hide attachment content
sdoh

Hi All, I was trying to extend Silverstripe/Userforms, but instead decided to recreate my form using regular Silverstripe/Form code.

I have some fields that only need to display if the user selects something specific in another field, i.e. they pick 'option A' in a dropdown, and it makes 5 checkbox fields display, or a textbox display, etc.

What is the best way to accomplish with silverstripe? Is this just a matter of creating all of the form fields with php, and then using js to manipulate on the front?

Or is there some way to add conditional logic via php to the forms?

StefGuev

I want to add a <img> tag just before the Title inside a DropdownField. Is it possible to do that?

Mo

Last time I did something similar I ended up creating my own version of DropdownField and changeing the template

Mo

Rather, creating a custom template for the new field type

Mo

And something like this in the template?

Mo

(I literally just made that up, so it may need some modification)

Mo

Obviously when you create the field you will have to set the image to the field

StefGuev

humm you mean http://DropdownWithImageField_holder.ssor http://DropdownWithImageField.ss ?

Mo

If you want the image to appear before the label, it has to be in the holder

Mo

the label is rendered in the field holder template

StefGuev

humm I'm getting the error [Warning] filemtime(): stat failedIt miss the http://DropdownWithImageField.ss

Mo

Hmm, that is annoying, it should fall back to using http://DropdownField.ss

StefGuev

no error but nothing.. i think to JS is not loaded for my new DropdownField

StefGuev

oh i'm near to resolve the problem Undefined property: DropdownWithImageField::$Image


Show less replies
Mo

Yea, I am now just struggling to get a load of json into a data attribute

Ed Linklater

yeah, only entwine will be aware of navigation within the CMS

Mo

to be honest, that makes more sense anyway

Mo

I am just re-writing it to try and use a data attribute instead

Mo

but the chart data depends on the record loaded