markhuot / craft-pest

https://craft-pest.com
Other
38 stars 11 forks source link

Virtual fields #62

Closed ostark closed 1 year ago

ostark commented 1 year ago

Emulate js dom manipulation

Example: Optional form fields that are created on-the-fly

markhuot commented 1 year ago

This is interesting! I'm not sure I understand the use case though? Why test form fields that aren't on the page?

ostark commented 1 year ago

Why test form fields that aren't on the page?

https://github.com/fortrabbit/spoke-and-chain-pestphp/blob/pest/templates/_includes/components/address/fields.twig#L74-L87

markhuot commented 1 year ago

Ah, yup… 🤔 let me think on this, I have an idea similar to how ->fill() currently works that might unify the logic.

ostark commented 1 year ago

I like the current behavior of ->fill() not supporting fields it can not find. What's on your mind?

markhuot commented 1 year ago

I got the tests passing, but I’m not sure why you’re using a virtual field instead of a regular input? Is there a good reason for the custom dom element?

https://github.com/markhuot/craft-pest/pull/67/files#diff-59e93e6fb927abb49192fbc83b7ef73371ad3e093b25b8177a5aea0772949f65R57

Also, I’d like to suggest renaming ->fake to ->addField if that’s okay?