Support

Account

Home Forums Feature Requests [Flexible Content] Auto add block if there is only one choice

Solving

[Flexible Content] Auto add block if there is only one choice

  • Maybe could be sounds strange, but sometime you could use the flexible content field only with a single block content type.
    This way, when a user click the “add element” button, a new element block should be automatically added without opening any popup selector.
    Popup selector is useless if you have only one choice. And Users have to click twice to add only that block type.

  • I submitted a patch to the author that gave you a layout to automatically add rows up to the minimum row count for that layout.

    It was rejected because they felt that it would complicate the forms too much.

    I believe that many people use flexible content to layout their fields and this could make the fields automatically appear if that is what the field designer wanted.

  • @trex005, is this on github or somewhere? While it may not be something the developer wants to incorporate, maybe it’s something that you could create an add on with? Have you looked at creating some type of extension rather than altering core ACF?

  • Since the flexible-content field is only in the pro, I don’t think it’d be a good idea for me to include the full file, but here is a diff:
    https://gist.github.com/trex005/409f1fd873b9487a040ec79b6440a0cf

    If there is any interest I can look into turning it into an addon.

  • There is a slight tweak one could make to that diff to hide the $no_value_message if relevant. If the dev has any interest in changing their mind, I could make that tweak as well.

  • Looking into making this an addon, if the developers gave us hooks into field types’
    render_field
    render_field_settings

    it would be doable, but I don’t see how to do it without that.

    Those hooks would not be too difficult to add to acf_field, and then we could have the field types call parent::render_field() and parent::render_field_settings() respectively.

Viewing 6 posts - 1 through 6 (of 6 total)

The topic ‘[Flexible Content] Auto add block if there is only one choice’ is closed to new replies.