Bringing the forms package up to scratch

92 views
Skip to first unread message

Adam Bouqdib

unread,
Mar 7, 2014, 5:30:40 AM3/7/14
to joomla-dev...@googlegroups.com
Hi,

I'm very interested in bringing the forms package up to scratch as I'm currently using it for a commercial project and already have extended it locally.
I now want to give it a big push including creating forms from JSON & YAML, porting the new HTML5 fields from the Joomla! CMS and possibly add the ability for namespaced fields as discussed here.
I also noticed that when a field is set to required it only adds a class, rather than an attribute... what's that all about? :P
Is the anything else that's import to include at this stage? Also in regards to field types...

Since I'll invest quite a bit of time I wouldn't want to do any duplicate work so if anyone else is currently on the forms package please let me know.

Thanks.

Hannes Papenberg

unread,
Mar 7, 2014, 1:27:39 PM3/7/14
to joomla-dev...@googlegroups.com
I would say that JForm needs a complete overhaul... While the fields are
okay, JForm itself is not really good... Basically, I'd like to see a
class that reads the XML (and potentially other form definition formats
as you described) in and then provides a unified interface to access
that data. Then you have a class that does the validation of data
against that first class and another that renders the form fields. Last
but not least, it would be cool if fields could define (via an XML) its
parameters and also render a non-form version of its data. Then you
could really create a Form component with JForm.

I currently don't like JForm, because the class is simply way to big and
includes way to many stuff for one class.

What I wrote above is A LOT to handle. You don't have to take all that
up by yourself. While I can't invest fulltime into this, I will be able
to support you with code review, etc. and I promise to test your PRs.
Just remember to not make them too big. Feel free to contact me
privately to give you support in this.

Hannes

Am 07.03.2014 11:30, schrieb Adam Bouqdib:
> Hi,
>
> I'm very interested in bringing the forms package up to scratch as I'm
> currently using it for a commercial project and already have extended
> it locally.
> I now want to give it a big push including creating forms from JSON &
> YAML, porting the new HTML5 fields from the Joomla! CMS and possibly
> add the ability for namespaced fields as discussed here
> <https://github.com/joomla/joomla-framework/issues/303#issuecomment-29673392>.
> I also noticed that when a field is set to required it only adds a
> class, rather than an attribute... what's that all about? :P
> Is the anything else that's import to include at this stage? Also in
> regards to field types...
>
> Since I'll invest quite a bit of time I wouldn't want to do any
> duplicate work so if anyone else is currently on the forms package
> please let me know.
>
> Thanks.
> --
> Framework source code: https://github.com/joomla/joomla-framework
> Visit http://developer.joomla.org for more information about
> developing with Joomla!
> ---
> You received this message because you are subscribed to the Google
> Groups "Joomla! Framework Development" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to joomla-dev-frame...@googlegroups.com
> <mailto:joomla-dev-frame...@googlegroups.com>.
> Visit this group at http://groups.google.com/group/joomla-dev-framework.

Don Gilbert

unread,
Mar 7, 2014, 2:59:48 PM3/7/14
to joomla-dev...@googlegroups.com, joomla-dev...@googlegroups.com
I've done some work on JForm that arose after experiencing much frustration with it's interface. A bit of that work was brought into J!3 when a GSOC student picked up my unmerged PR last year and brought it up to snuff. 

I've also attempted to do some work on the Form package under the Framework that would allow you to use different form definition formats (like YAML or JSON). I was really going for any format supported by our Registry package, but that package had a whole slew of problems on it's own, so that didn't work out too well. 

I said all that to say I'm very happy to see someone else interested in improving the package. I'll definitely help test the PR's and review the code. 

Sent from my iPhone
--
Framework source code: https://github.com/joomla/joomla-framework
Visit http://developer.joomla.org for more information about developing with Joomla!
---
You received this message because you are subscribed to the Google Groups "Joomla! Framework Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-frame...@googlegroups.com.

Adam Bouqdib

unread,
Mar 12, 2014, 10:14:31 AM3/12/14
to joomla-dev...@googlegroups.com
Hi again,

Sorry about the late reply, I've just been catching up on work. 

I had a deeper look into the forms and registry packages and I'm starting to see more of the issues. 
I like the idea of creating a form from a registry object as that would save a lot of duplicate work when it comes to supporting different data formats and one other important issue in my opinion is custom HTML attributes. Rather than have fixed attributes I like the idea of being able to add any attributes you want on any field as these days with HTML5 data attributes and such there's no saying what they might be called.

Could you send me a link to the work you've already done regarding using the registry package? As long as there's no objections I'm going to start with that first as the ability to create forms from JSON, YAML etc. is one of the main priorities for my own project.

I'm excited as I've been making a living out of Joomla since 2007 so the idea of giving something back is pretty awesome lol.

Don Gilbert

unread,
Mar 12, 2014, 10:48:06 AM3/12/14
to joomla-dev...@googlegroups.com
This is where I was at - it didn't take long to realize that the Registry package was going to require some work for this to come to life - I didn't get very far, but here it is https://github.com/dongilbert/joomla-framework/tree/refactor-JForm

You'll see here that I created a "FormImproved" class where I was starting the refactor - https://github.com/dongilbert/joomla-framework/commit/d53442552fa433b27dc3ad9c2d9d434b5f1cf94d#diff-e154cfbf28d2fcf210e5714623619e51R1


--

Adam Bouqdib

unread,
Mar 12, 2014, 12:14:43 PM3/12/14
to joomla-dev...@googlegroups.com
Nice one thanks. What was the main issue with the registry package at this stage? 
To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-framework+unsub...@googlegroups.com.

Don Gilbert

unread,
Mar 12, 2014, 12:29:21 PM3/12/14
to joomla-dev...@googlegroups.com
Main issue was the XML support in Registry. It doesn't use clear semantic markup. Instead of <form><fieldset><field name="foo"></fieldset></form> it uses <node name="form"><node name="fieldset">etc</node></node> - It's not a good representation of the data.

Adam Bouqdib

unread,
Mar 12, 2014, 12:36:55 PM3/12/14
to joomla-dev...@googlegroups.com
Ah I see. I'll have a closer look at that first then. If I update the XML package of Registry should I report back here or just create a pull request?

Adam Bouqdib


On 12 March 2014 17:29, Don Gilbert <dilber...@gmail.com> wrote:
Main issue was the XML support in Registry. It doesn't use clear semantic markup. Instead of <form><fieldset><field name="foo"></fieldset></form> it uses <node name="form"><node name="fieldset">etc</node></node> - It's not a good representation of the data.

--
Framework source code: https://github.com/joomla/joomla-framework
Visit http://developer.joomla.org for more information about developing with Joomla!
---
You received this message because you are subscribed to a topic in the Google Groups "Joomla! Framework Development" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/joomla-dev-framework/ASBkHvanpOA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to joomla-dev-frame...@googlegroups.com.

Don Gilbert

unread,
Mar 12, 2014, 12:39:59 PM3/12/14
to joomla-dev...@googlegroups.com
You can report back here as well with a link to it, so others interested may find it. I'll see the PR come in, but others won't necessarily see it.

Thanks again!

Adam Bouqdib

unread,
Mar 12, 2014, 4:27:52 PM3/12/14
to joomla-dev...@googlegroups.com
Is it OK to still use SimpleXML?

Don Gilbert

unread,
Mar 12, 2014, 4:58:41 PM3/12/14
to joomla-dev...@googlegroups.com, joomla-dev...@googlegroups.com
Certainly

Sent from my iPhone
--
Framework source code: https://github.com/joomla/joomla-framework
Visit http://developer.joomla.org for more information about developing with Joomla!
---
You received this message because you are subscribed to the Google Groups "Joomla! Framework Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-frame...@googlegroups.com.

piotr_cz

unread,
Mar 13, 2014, 5:59:16 AM3/13/14
to joomla-dev...@googlegroups.com
I don't think an XML object can be simply converted to Registry. If we would manage to do so, I'm afraid it would be easier to manipulate XMLDocument than Registry result.

I'm for renaming the `Registry\Format\Xml` to `Registry\Format\XmlValues` or something that's not so misleading. See https://github.com/joomla/joomla-framework/pull/287

Adam Bouqdib


To unsubscribe from this group and all its topics, send an email to joomla-dev-framework+unsub...@googlegroups.com.

Adam Bouqdib

unread,
Mar 22, 2014, 7:32:40 PM3/22/14
to joomla-dev...@googlegroups.com
Hi. I've just started on this and I'm not sure I understand the issue... What's wrong with parsing the XML like this:

public function stringToObject($data, array $options = array())
{
   
// Parse the XML string.
    $xml
= simplexml_load_string($data);
    $obj
= json_decode(json_encode($xml));
   
   
return $obj;
 
}

That way we have a real representation of the XML data and it makes it easy to create a form from this. I'm not too keen on the attributes being inside @attributes, but that can easy be changed by recursively looping through the object.

To determine what format this should be saved as it would be good to agree on how non XML forms should be. I personally quite like the idea of loading a JSON string like this:

{"fields":[
   
{"label":"Test","type":"text","name":"test","required":true},
   
{"label":"Test2","type":"text","name":"test2"}
]}
Reply all
Reply to author
Forward
0 new messages