Robin S Posted April 29, 2017 Share Posted April 29, 2017 3 hours ago, Pixrael said: Just installed in PW 3.0.61 .. when add new field type YAML and save I get the following error: Session: Warning (showIf): dependency field 'contentType' is not present in this form. (ProcessFieldEdit) This is because the module extends Fieldtype Textarea but removes certain config inputfields (including contentType) that are not to be used with Fieldtype YAML. I'm guessing that the core Fieldtype Textarea has added an inputfield dependency for contentType since the Fieldtype YAML module was created, hence the warning. @owzim, maybe the module could set the unused config inputfields to hidden rather than not including them in the field config at all? foreach($parentInputfields as $inputfield) { if(in_array($inputfield->name, $forbidden)) { $inputfield->collapsed = Inputfield::collapsedHidden; } $inputfields->append($inputfield); } 4 Link to comment Share on other sites More sharing options...
Pixrael Posted May 1, 2017 Share Posted May 1, 2017 Thanks Robin! Works!.. for the moment I modified the source code of my installed module :-( Link to comment Share on other sites More sharing options...
szabesz Posted July 21, 2017 Share Posted July 21, 2017 On 2017-4-29 at 7:46 AM, Robin S said: @owzim, maybe the module could set the unused config inputfields to hidden rather than not including them in the field config at all? foreach($parentInputfields as $inputfield) { if(in_array($inputfield->name, $forbidden)) { $inputfield->collapsed = Inputfield::collapsedHidden; } $inputfields->append($inputfield); } @owzim Hi, any chance of applying this fix? Thank you in advance. Link to comment Share on other sites More sharing options...
szabesz Posted July 22, 2017 Share Posted July 22, 2017 I have just tested @owzim's other great module InputfieldAceExtended which works perfectly if we want to use syntax highlighting for YAML. However, @Robin S's suggestion to fix the error changes the Details Tab, making it impossible to configure the InputField Type as seen in the screenshots below: original: after applying the suggestion: Spoiler Link to comment Share on other sites More sharing options...
Pixrael Posted August 5, 2019 Share Posted August 5, 2019 Does anyone know how to save an Array or a WireArray back to the YAML field in the page? In the source code I saw some functions for "Dump", but I don't know which one would be the right one, or how to use it. Link to comment Share on other sites More sharing options...
Pixrael Posted August 6, 2019 Share Posted August 6, 2019 HELP Link to comment Share on other sites More sharing options...
Pixrael Posted August 12, 2019 Share Posted August 12, 2019 On 8/6/2019 at 6:23 PM, Pixrael said: HELP Any help? Link to comment Share on other sites More sharing options...
Macrura Posted August 12, 2019 Share Posted August 12, 2019 AFAIK the module does not provide any class to convert array to YAML. the purpose of the module is an inputfield, for YAML formatted text, and has options for output into various formats, but it does not provide any interface for Array to YAML. If you convert your array to JSON, you may be able to find an online converted that can generate YAML from JSON... Link to comment Share on other sites More sharing options...
Robin S Posted August 13, 2019 Share Posted August 13, 2019 On 8/6/2019 at 10:10 AM, Pixrael said: Does anyone know how to save an Array or a WireArray back to the YAML field in the page? As stated in the module readme, FieldtypeYaml uses a namespaced version of Spyc. And the examples for Spyc show how to dump an array to YAML: https://github.com/mustangostang/spyc/blob/master/examples/yaml-dump.php So to reproduce that example using the namespaced Spyc bundled with FieldtypeYaml: // Init the module so Spyc gets loaded $modules->get('FieldtypeYaml'); // Some array data $array[] = 'Sequence item'; $array['The Key'] = 'Mapped value'; $array[] = array('A sequence','of a sequence'); $array[] = array('first' => 'A sequence','second' => 'of mapped values'); $array['Mapped'] = array('A sequence','which is mapped'); $array['A Note'] = 'What if your text is too long?'; $array['Another Note'] = 'If that is the case, the dumper will probably fold your text by using a block. Kinda like this.'; $array['The trick?'] = 'The trick is that we overrode the default indent, 2, to 4 and the default wordwrap, 40, to 60.'; $array['Old Dog'] = "And if you want\n to preserve line breaks, \ngo ahead!"; $array['key:withcolon'] = "Should support this to"; // Dump to YAML with some (optional) custom indent and wordwrap settings $yaml = \owzim\FieldtypeYaml\Vendor\Spyc::YAMLDump($array,4,60); // See the result in a Tracy dump bdb($yaml, 'yaml'); You can convert a WireArray to a plain array with getArray(). 4 Link to comment Share on other sites More sharing options...
Pixrael Posted August 13, 2019 Share Posted August 13, 2019 WOW! .. THANKS @Robin S ..You always helping! I'll try this ? 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now