• Resolved companyatif

    (@companyatif)


    I have an application form featuring checkboxes for 20 workshops, each displaying their respective dates and venues. My goal is to retain visibility of all workshop options while disabling the ability to select checkboxes for workshops that have already occurred.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support Kris – WPMU DEV Support

    (@wpmudevsupport13)

    Hi @companyatif

    I hope you are doing well today.

    I pinged out SLS Team to review your query and see what will be possible in this case. We will post an update here as soon as more information is available.

    Kind Regards,
    Kris

    Plugin Support Nithin – WPMU DEV Support

    (@wpmudevsupport11)

    Hi @companyatif,

    We would like to check this further with the current form setup you have configured.

    Possible to also share the form export, so that we could check further?

    Please check the following doc on how to export a form:
    https://wpmudev.com/docs/wpmu-dev-plugins/forminator/#import-export

    If you are concerned about any sensitive information in the form, then you can duplicate your form, remove any sensitive information, and then export it.

    You can share the export file via Google Drive, Dropbox or any cloud services in the next reply.

    Looking forward to your response.

    Best Regards,

    Nithin

    Plugin Support Nithin – WPMU DEV Support

    (@wpmudevsupport11)

    Hi @companyatif,

    Our developer have managed to figure out a workaround, could you please try this snippet and see how it goes?

    <?php
    add_action( 'forminator_before_form_render', 'wpmudev_checkbox_field_form', 10, 5 );
    function wpmudev_checkbox_field_form( $id, $form_type, $post_id, $form_fields, $form_settings ) {
    	if ( 1388 == $id ) { // Please change the form ID.
    		add_action( 'forminator_field_multiple_markup', 'wpmudev_checkbox_field_selection', 10, 5 );
    	}
    }
    
    function wpmudev_checkbox_field_selection( $html, $id, $required, $options, $value_type ) {
        if ( strpos( $id, 'checkbox-1' ) !== false ) {
            foreach ( $options as $key => $value ) {
                $pieces     = explode( '<br />', $value['label'] );
                $date       = implode( '<br />', array_slice( $pieces, 0, 1 ) );
                $date       = strtotime( str_replace( array( '. ', '-' ), '', $date ) );
                $date_now   = time();
                if ( $date_now > $date ) {
                    $html = str_replace( 'value="'.$value['value'].'"', 'value="'.$value['value'].'" disabled', $html );
                }
            }
        }
        
        return $html;
    }

    You’ll have to update the following line in the above code to your form ID.

    Suppose the from ID is 123 then the following line will change from:

    <span style=”color: rgb(23, 43, 77); font-family: SFMono-Medium, "SF Mono", "Segoe UI Mono", "Roboto Mono", "Ubuntu Mono", Menlo, Consolas, Courier, monospace; font-size: 14px; text-wrap: nowrap; background-color: rgba(9, 30, 66, 0.06);”> if ( 1388 == $id ) { // Please change the form ID. </span>

    To:
    if ( 123 == $id ) { // Please change the form ID.<span class=”comment linenumber ds-line-number” data-ds–line-number=”4″ style=”flex-shrink: 0; box-sizing: border-box; padding-left: 8px; margin-right: 8px; text-align: right; user-select: none; float: left; font-family: SFMono-Medium, "SF Mono", "Segoe UI Mono", "Roboto Mono", "Ubuntu Mono", Menlo, Consolas, Courier, monospace; font-size: 14px; text-wrap: nowrap; background-color: rgba(9, 30, 66, 0.06); display: inline-block !important; min-width: calc(2ch + 16px) !important; color: var(–ds-text-subtlest, #505F79) !important; padding-right: 8px !important;”></span><span style=”color: rgb(23, 43, 77); font-family: SFMono-Medium, "SF Mono", "Segoe UI Mono", "Roboto Mono", "Ubuntu Mono", Menlo, Consolas, Courier, monospace; font-size: 14px; text-wrap: nowrap; background-color: rgba(9, 30, 66, 0.06);”></span>

    Please check this link on how to implement the above code as a mu-plugins:
    https://wpmudev.com/docs/using-wordpress/installing-wordpress-plugins/#installing-mu-plugins

    Best Regards,

    Nithin

    Plugin Support Williams – WPMU DEV Support

    (@wpmudev-support8)

    Hi @companyatif

    We didn’t get any feedback from you for quite some time already so I’m assuming suggested solution worked and I’m marking this as resolved.

    If you still need assistance, let us know and we’ll be happy to help.

    Kind regards,
    Adam

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to disable Checkbox option from selecting without hiding the option’ is closed to new replies.