-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding removeField and modifyField to GroupBuilder + Tests #142
Conversation
Hey @Androlax2, thanks for your collaboration. I'm trying to use the PR #91 to modify a repeater subfield without success. Could you take a look on the issue #141? |
Hey @marcelo2605, could you send me all the code please.
Give me this part :
I will make some tests to see where is the problem. |
Sure @Androlax2. This is the content of
|
…ld with `modifyField`
@marcelo2605 Could you try with this fix please ? I added the possibility to use a dot notation to go through the items. You would do something like this now
I don't know if the mainteners will accept this. If yes, we will need to refactor this, I did it just to make the test pass. Only one level deep is tested for now. |
@Androlax2 its works in the way you mentioned. But when I try to use a function, it return a |
@marcelo2605 Yeah it's harder to do it with the |
@stevep If you are ok, I can deep the code and do something with this dot notation with tests etc... It may be nice to have this deep level modify/remove method for this package. |
Hey guys... any update for this? I have a launch in some days and it would be great to have this PR in place to do not harcoding the package 😄 . I think this will be really helpful. |
@Androlax2 thanks for doing this, I think this is great and will help people. The code and tests looked good to me, I merged it. I'm not sure what you meant by your last message though, the dot notation was present in the 2nd commit
@capellopablo this is on the master branch now, I can do a release in a bit but want some clarification from @Androlax2 if this is considered complete or not. |
Ok @Androlax2 @capellopablo @marcelo2605 I pushed a new code to develop and master branches that builds upon the code here. For deep nesting I changed using d7dce8b#diff-387508aa2a6461e10fda9888c2fc11a4789d12a65dfebbaabea92a0ccbffa0a7 |
I hadn't pushed a test for it yet, but you also don't need to use deep nesting either. The following will now work. $subject = new FieldsBuilder('test');
$subject
->addRepeater('items')
->addText('headline');
$subject->getField('items')->modifyField('headline', [
'wrapper' => [
'width' => '77%'
]
]); |
Thank you! the All that's left is to update the documentation https://github.com/StoutLogic/acf-builder/wiki/modifying-fields |
@Androlax2 I hear ya about the dot notation. I just worry about a hypothetical user who might named a field something like Then I thought about making the delimiter a public static variable on I will get this wrapped up into a release today, along with removing deeply nested fields and update the wiki. Thanks for your help on this. |
@stevep Yes, of course I understood the problem with the point notation. Maybe it would be wise in a major version to put a dot instead of the ->? This is only my opinion of course, see what other people think, but I find it quite unnatural to use -> in a string when a . doesn't necessarily bother (thanks to the frameworks and others that use this notation). See if it is really necessary. |
…esting. #142 #91 #141 #82 If modifying a Layout (FieldsBuilder), pass updated array config to FieldsBuilder::updateGroupConfig This change also calls removeField and modifyField recursively along the nesting path, so the correct modify / remove action can be taken if running into a Flexible Content field
In the interest of getting this feature finally out there I'm going to release with the arrow as the shorthand. We can revisit the dot notation later, potentially using both arrow and dot notation if and when a new major version with other breaking changes is released. Also added is the ability to modify / remove nested flexible content fields and layouts. The wiki has been updated. Let me know if any parts in there aren't clear. Thanks again. |
Thanks so much! It's working perfect! |
Hi,
It should close this PR #91
Added unit tests for the GroupBuilder
modifyField
andremoveField