Forum Replies Created
-
AuthorPosts
-
August 25, 2020 at 1:09 PM in reply to: ✅Cannot submit front-end from embedded within an iframe #21445
Przemek
ParticipantHello,
Thank you for looking at this.
The page (being within an iframe; let's call it "primary" page) with form tries to create PHPSESSID cookie when opened on "secondary" page. As for now it works in Firefox, doesn't work in Chrome (session, when https, should be started with params: 'Secure' => 1 'SameSite' => 'None') and doesn't work in Safari (is blocking third party cookies like this one PHPSESSID by default).
As the form submission relies on this session cookie, I think nothing can be done to override Safari policy here.
August 24, 2020 at 6:35 PM in reply to: ✅Cannot submit front-end from embedded within an iframe #21432Przemek
ParticipantAfter investigation I found that the issue is caused by the fact that MBFS form page loading in iframe tries to set up PHP session cookie. It could be secure cookie under https - then it would be solvable in Chrome - but Safari blocks all 3-party cookies by default anyway.
I don't know if MBFS really, really needs this session cookie, however, this makes my setup impossible to implement with MB causing me to be very sad...
August 22, 2020 at 12:56 PM in reply to: ✅Cannot submit front-end from embedded within an iframe #21398Przemek
ParticipantDid you test with a non-Ajax form as well?
I can for example add comment to the host site but I cannot submit MBFS form. It just reloads.
August 21, 2020 at 7:10 PM in reply to: ✅Cannot submit front-end from embedded within an iframe #21388Przemek
ParticipantHello!
Thank you for your testing.
Actually, I should have check it and mention that the iframe embedded on the host site works for me as well.
However, the story is about the iframes embedded under different domains than that where MB is installed. (Perhaps it should be something different than "localhost" to reproduce the case; I use 2 domains in Local by Flywheel app like primary-site.local and secondary-site.local.
August 21, 2020 at 3:14 PM in reply to: ✅Cannot submit front-end from embedded within an iframe #21378Przemek
ParticipantBy the way, I'm using Metabox All in One and it claims about the missing CSS file:
https://(...)/wp-content/plugins/meta-box-aio/vendor/meta-box/mb-frontend-submission/assets/css/frontend-submission.css?ver=2.0.0Przemek
ParticipantIt would be great to see this feature in MB, especially as ACF has just announced it for 5.9 update. They are going to parse <InnerBlocks /> component in PHP template.
Przemek
ParticipantHello, thank you for taking a look at that.
So far I'm using a workaround to keep MB Builder and validations together.
- I disabled Ajax for front-end forms
- I added a filter which modifies existing meta boxes by inserting validation formulas
add_filter( 'rwmb_meta_boxes', 'prefix_meta_boxes_validation_rules', 999 ); /** * Add validation rules to existing meta boxes. * * Filter hook: 'rwmb_meta_boxes' * * @since 1.0.0 * * @param array $meta_boxes Meta Box plugin's meta boxes. */ function prefix_meta_boxes_validation_rules( $meta_boxes ) { foreach ( $meta_boxes as $i => $meta_box ) : $required = []; foreach ( $meta_box['fields'] as $field ) : if ( isset( $field['required'] ) && $field['required'] ) : $required[] = [ $field['id'] => [ 'required' => 1 ] ]; endif; endforeach; if ( ! empty( $required ) ) : $meta_boxes[$i]['validation'] = [ 'rules' => $required ]; endif; endforeach; return $meta_boxes; }Przemek
ParticipantSome additional observations.
Safari, Chrome, WP 5.3.2, TwentyTwenty themeWhen I defined the fields in PHP instead of MB Builder with 'validation' attribute like below:
'validation' => array( 'rules' => array( $prefix . 'first-name' => array( 'required' => 1, ), $prefix . 'last-name' => array( 'required' => 1, ), ), )- Validation errors are properly visible in non-Ajax submit
- Validation errors are replaced with success message in Ajax submit
- In both cases the fields labels have duplicated asterisk marking required fields "* *"
- When I don't use 'validation' attribute and rely just on browser's validation, the submit field remains "disabled" when I fill the fields after initial submit attempt and cannot be re-submitted (non-Ajax form)
I'm sad a bit as I wanted to use all this stuff on production without installing third-party plugins...
Przemek
ParticipantI'm not familiar with MB Block internals, but in pure Gutenberg there are just 2 steps: registering post meta in PHP and defining "source: 'meta', meta: 'meta_field_key'" in JS block declaration. I feel that it might be not a big leap in MB code.
Przemek
ParticipantIf one field in each blog has different values, then there’s no way to decide which value will be save in the post meta.
Anh, I understand your point, but the fact is that blocks are created by aware developers and Gutenberg itself gives the possibility of storing data in post meta. (For example, it is enough to allow one such block per post and potential confusion is over)
I think there are many use cases for this.
An instant example from me five minutes ago: I want to create a block including editable featured image and it would be great if this advice would work in MB Blocks: https://support.metabox.io/topic/adding-fields-to-featured-image-metabox/December 19, 2019 at 4:50 PM in reply to: ✅How to render block in edit mode by default or trigger edit on load? #17585Przemek
ParticipantSuch small while so useful!
Thank you!December 16, 2019 at 6:00 PM in reply to: ✅How to render block in edit mode by default or trigger edit on load? #17544Przemek
ParticipantThat's great! Thank you.
December 14, 2019 at 4:29 PM in reply to: ✅How to render block in edit mode by default or trigger edit on load? #17527Przemek
ParticipantI just had clients recently who needed to fill a large number of inputs within multiple blocks across many posts and they didn't want to click edit every single time.
Also, I have some blocks that do not render anything interesting but store important data.
Przemek
ParticipantHi, I'm not sure if ACF can do it. Is it documented?
I mean exactly sidebar panels (Gutenberg-based), not just meta boxes aside.Przemek
ParticipantThank you Anh, there are so few tools that make it easy, that it could be a very valuable feature of your plugin.
-
AuthorPosts