Creating New Fields in ICA-Atom DC Template

126 views
Skip to first unread message

Prathmesh

unread,
Jan 10, 2013, 10:48:20 AM1/10/13
to qubi...@googlegroups.com
I am trying to add some new "free-text" fields from scratch in the DC template of the ICA-Atom. I did refer the following forum post  : https://groups.google.com/forum/?fromgroups=#!topic/qubit-dev/RFdBCO9Tmqk ; and was able to create a free-text field within the RAD plugin similar to the "Standard Number" . But when I tried the same logic and same code changes within the DC template, it doesn't seem to work & it gives me an error saying the new field is not properly defined. 
Is there some different approach to be taken for the DC template as compared to RAD. 
Can someone provide me an example if one's has already implemented adding a new field using the "property" entity in DC template OR can the developers give me an example of which files needs to modified within the DC plugin. 

Any help is appreciated , Thanks !

-Prathmesh

David Juhasz

unread,
Jan 16, 2013, 5:43:58 PM1/16/13
to qubit-dev
Hi Parthmesh,

There isn't any special considerations that I'm aware of when adding a field to the DC template that are different from the RAD plugin. 

Are you getting the error on the index or edit template for the DC plugin?   Can you please post your code, so we can analyze it?

Regards,
David



-Prathmesh

--
You received this message because you are subscribed to the Google Groups "Qubit Toolkit Developers" group.
To view this discussion on the web visit https://groups.google.com/d/msg/qubit-dev/-/D-QuIzC1XM8J.
To post to this group, send email to qubi...@googlegroups.com.
To unsubscribe from this group, send email to qubit-dev+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/qubit-dev?hl=en.



--
David Juhasz
Director, Technical Services

Artefactual Systems Inc.
www.artefactual.com

Prathmesh

unread,
Jan 17, 2013, 3:05:58 PM1/17/13
to qubi...@googlegroups.com
Hi David,

     I am getting the following error when I try to go to add a new Archival Description using DC Template, it says :

500 | Internal Server Error | InvalidArgumentException

Widget "testfield" does not exist.

 
I have defined the case "testfield" within the set and get () in the  sfDCclassplugin.php . And also defined an array with the same name and create the case for the testfield in the addField and ProcessField () in the editaction.class.php.

Does it need to be defined in the indexaction.class.php too even if its not a mandatory field ?

And 1 more question , so should I use scope $dc instead of $rad.

Thanks,
Prathmesh

David Juhasz

unread,
Jan 17, 2013, 3:17:23 PM1/17/13
to qubit-dev
Hi Prathmesh,

If it's a simple text field you should just need to add it to the sfDcPluginEditAction::$NAMES array.

Regards,
David


To view this discussion on the web visit https://groups.google.com/d/msg/qubit-dev/-/kiafJjqM900J.

To post to this group, send email to qubi...@googlegroups.com.
To unsubscribe from this group, send email to qubit-dev+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/qubit-dev?hl=en.

David Juhasz

unread,
Jan 17, 2013, 3:18:15 PM1/17/13
to qubit-dev

Prathmesh Mengane

unread,
Jan 17, 2013, 5:13:45 PM1/17/13
to qubi...@googlegroups.com
Hi David,

  Are you suggesting that I should just define the new field only in the sfDcPluginEditAction::$NAMES array. And not to create cases for it in the addField & processField functions and not even to mention it in the sfDCclassplugin.php  , did I understand you right ?

I tried trying the above and I am still getting the same Error . Maybe I understood you wrong. 

Is there a field within the dc template which I can try and replicate, for example how about "Description" field using "scopeAndcontent" ? 

Additionally, in the editsuccess.php file do I store the new field under "$resource" variable like Description field OR do should I use some other variable like $dc or $rad ( as explained for the standard number field )

Thanks for your quick responses : )

-Prathmesh

David Juhasz

unread,
Jan 17, 2013, 5:38:06 PM1/17/13
to qubit-dev
However, if you are mapping your new field to a related QubitProperty row, then you will need to add some code to sfDcPluginEditAction::processField() to handle creating, updating or deleting the QubitProperty row. 

A good example of this can be found in the sfRadPluginEditAction code for "editionStatementOfResponsibility":
https://github.com/artefactual/atom/blob/1.x/plugins/sfRadPlugin/modules/sfRadPlugin/actions/editAction.class.php#L193

The example above for "editionStatementOfResponsibility" is calling the __get() and __set() method you have created in plugins/sfDcPlugin/lib/sfDcPlugin.class.php:
https://github.com/artefactual/atom/blob/1.x/plugins/sfRadPlugin/lib/sfRadPlugin.class.php

Also note the way that the "$rad" object is referenced for "editionStatementOfResponsibility" in the editSuccess page:
https://github.com/artefactual/atom/blob/1.x/plugins/sfRadPlugin/modules/sfRadPlugin/templates/editSuccess.php#L133

You should use this syntax (with a $dc object) with the render_field() helper.


Regards,
David




-Prathmesh

--
You received this message because you are subscribed to the Google Groups "Qubit Toolkit Developers" group.
To view this discussion on the web visit https://groups.google.com/d/msg/qubit-dev/-/aG4OIDzg-TgJ.

To post to this group, send email to qubi...@googlegroups.com.
To unsubscribe from this group, send email to qubit-dev+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/qubit-dev?hl=en.

Prathmesh

unread,
Jan 18, 2013, 4:49:06 PM1/18/13
to qubi...@googlegroups.com
Hey David ,

    So I tried few things but I am still not able to get rid of the same Error...


500 | Internal Server Error | InvalidArgumentException

Widget "testfield" does not exist.

stack trace

  • at ()
    in SF_ROOT_DIR/vendor/symfony/lib/form/sfForm.class.php line 1067 ...
      1.     {
      2.       if (!$widget $this->widgetSchema[$name])
      3.       {
      4.         throw new InvalidArgumentException(sprintf('Widget "%s" does not exist.'$name));
      5.       }

      6.       if ($this->isBound)



Prathmesh

unread,
Jan 18, 2013, 4:59:32 PM1/18/13
to qubi...@googlegroups.com
I am still able to create new text-fields within the RAD plugin but it seems to just give me error for the DC Template...there's probably something obvious I'm making a mistake in. FYI, when I check the backend it does not create a row with the field name in the property table while Im attempting this in DC, but as I said when I add new field to RAD template it seems to add that field to the "property table". Just FYI,

So here are the only code changes I have implemented in order to achieve this , so you can have a look at it and let me know where I'm making the mistake :

In file sfDcPluginEditAction :  I added the name to the Array list

public static
    $NAMES = array(
      'accessConditions',
      'extentAndMedium',
      'editionStatementOfResponsibility',
      'identifier',
      'language',
      'locationOfOriginals',
      'placeAccessPoints',
      'repository',
      'scopeAndContent',
      'subjectAccessPoints',
      'title',
      'type',
      'testfield',
      'publicationStatus');

In editsuccess.php , I added this code snippet :

<?php echo render_field($form->testfield
    ->help(__('An abstract, table of contents or description of the resource\'s scope and contents.'))
    ->label(__('Inscription')), $resource, array('class' => 'resizable')) ?>

In indexsuccess.php , I added this one line :

<?php echo render_show(__('Inscription'), render_value($resource->gettestfield(array('cultureFallback' => true)))) ?>

Let me know if you need the whole Dc plugin code to analyze and a way for me to send it to you , other than Github ( because I didnt pull this instance from github in the first place )

Really appreciate the help,  Thanks !

Prathmesh

Jesús García Crespo

unread,
Jan 18, 2013, 5:40:23 PM1/18/13
to qubi...@googlegroups.com
Hi there,

I haven't read the whole conversation that you had with David but I think that you are missing a key part, defining your form field.

$NAMES is a list of fields in your form. That list is iterated and for each item, the addField method in the sfDcPluginEditAction will be called. Inside the switch block, you need to add a specific case for your new field name. There, you have to define your form field as part of $this->form, the property that holds the form object. Same for processField(), you need to define how the data that comes from the form must be processed and stored.

Also, please notice that sfDcPluginEditAction extends InformationObjectEditAction, also the latter extends DefaultEditAction. That allows us to define some common logic that we share between multiple parts of the application. If you take a look at the upper classes, all off them make use of the addField() method and if there is no match, the method will call the parent one and so on. If you are adding a new field that you want to share between multiple metadata standards, it would make more sense to use InformationObjectEditAction instead.

In other words, the error that you are getting makes perfect sense. You are trying to render a form widget from the template $form->testfield but you have not defined yet.

I had to add recently a field that it is used along isad, dc, mods and rad. You may find useful to take a look at the code:

Good luck!
--
Jesús García Crespo,
Software Engineer, Artefactual Systems Inc.
http://www.artefactual.com | +1.604.527.2056

Prathmesh

unread,
Jan 20, 2013, 4:36:59 PM1/20/13
to qubi...@googlegroups.com, je...@artefactual.com
Hi Jesus,

   Your explanation really helped and I was able to make some progress.  So I was able to define the form field by adding the following case within the addfield () in the sfDcPluginEditAction.

case 'testfield':
        $this->form->setDefault($name, $this->dc[$name]);
        $this->form->setValidator($name, new sfValidatorString);
        $this->form->setWidget($name, new sfWidgetFormInput);

        break;


And I am also able to succesfully show it in the Edit form . My problem is now is I am not able to store the value of the field & for that as you mentioned I would have to add a Case in the Process Field () within sfDcPluginEditAction. I did try to research the other plugins but couldnt find anything useful in how to store the input data of the field.

FYI,
In editsuccess.php , I added this code snippet :

<?php echo render_field($form->testfield
    ->help(__('An abstract, table of contents or description of the resource\'s scope and contents.'))
    ->label(__('Dimension')), $dc, array('class' => 'resizable')) ?>


In indexsuccess.php , I added this one line :

<<?php echo render_show(__('Dimension'), render_value($dc->testfield)) ?>

In the RAD plugin I followed an example of the Standard Number field and was able to create a test field in RAD where the data is stored successfully, but as you know the Case for standardnumber field in Processfield() is empty. When I try the same thing in DC by keeping the case empty in processfield() it doesnt seem to work.
The sucessfile doesnt show the field "dimension' and when I go back to edit the Entry that particular field is empty.

Can you please let me know what should I add in the processfield case in sfDcPluginEditAction so that I can store the text field user input appropriately .

Thanks a ton !
Prathmesh

Jesús García Crespo

unread,
Jan 20, 2013, 4:50:00 PM1/20/13
to qubi...@googlegroups.com
Hi there,

Please take a look at both sfRadPlugin.class.php and sfDcPlugin.class.php. The former is using a method called property() that abstracts the access to the object properties. The thing is that you are using the QubitProperty entity to add a new field in your information objects so you don't have to add an extra column in the database. That's find but there is no properties yet in sfDcPlugin AFAIK so you'll have to add the property() method first and then try to interact with it as we do in sfRadPlugin.

Let me know how it goes.

Regards,


Prathmesh

--
You received this message because you are subscribed to the Google Groups "Qubit Toolkit Developers" group.
To view this discussion on the web visit https://groups.google.com/d/msg/qubit-dev/-/Wsuz0huNVdkJ.

To post to this group, send email to qubi...@googlegroups.com.
To unsubscribe from this group, send email to qubit-dev+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/qubit-dev?hl=en.

Prathmesh

unread,
Jan 22, 2013, 5:06:23 PM1/22/13
to qubi...@googlegroups.com, je...@artefactual.com
Hi Jesus & David,

  I was able to successfully add new text fields to the DC Template . It was the property () which was the missing piece in the puzzle, adding it did do the trick.
Thanks a lot for you help & quick reply's !

Best,
Prathmesh

Jesús García Crespo

unread,
Jan 22, 2013, 5:15:22 PM1/22/13
to qubi...@googlegroups.com
Awesome, that's good news!

Remember that you can add the new field to the search index too!

Also, are you planning to share the code with the community? Remember that the source code of ICA-AtoM is available under the GNU Affero General Public License, version 3 license.

Thank you.


Prathmesh

--
You received this message because you are subscribed to the Google Groups "Qubit Toolkit Developers" group.
To view this discussion on the web visit https://groups.google.com/d/msg/qubit-dev/-/T_23KugKx1EJ.

To post to this group, send email to qubi...@googlegroups.com.
To unsubscribe from this group, send email to qubit-dev+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/qubit-dev?hl=en.

Prathmesh

unread,
Jan 23, 2013, 10:14:47 AM1/23/13
to qubi...@googlegroups.com, je...@artefactual.com
Thanks Jesus,

 I would like to add some of the new fields to search index but haven't done the research yet on how to do that, will be doing I once I get to it. If you have anything handy like documentation or tutorial on how to do so please point me towards it , thanks.

And yes I am planning to share the code with the community once I am done with the plugin. I'll get back to you then about the best way to do this and the best practices to follow before sharing. Thanks for sharing the information.

-Prathmesh

Dan Gillean

unread,
Jan 23, 2013, 12:53:57 PM1/23/13
to qubi...@googlegroups.com, je...@artefactual.com

Hello Prathmesh,

My name is Dan Gillean; I am an archivist and Systems Analyst with Artefactual. Since you have recently been having success with your development work to add a new field to a template (a customization we are often asked about), I thought I would invite you to consider submitting documentation to our developer's wiki, to help future developers faced with the same challenge. All of our documentation is based on the wiki model, and we encourage our user community to take an active role in helping us to improve and maintain it.

Documentation on development tends to get filed on the Qubit Toolkit wiki (an early name for the application which may be changing soon as we update our docs in advance of the AtoM 2.0 release). You can find the home page for Qubit Toolkit here: https://www.qubit-toolkit.org/wiki/Main_Page

Adding documentation will require registration, a free and relatively quick process. To request an account, start here: https://www.qubit-toolkit.org/wiki/Special:RequestAccount

There is a page dedicated to development documentation, here: https://www.qubit-toolkit.org/wiki/Category:Development_documentation
To add to this page, simply click edit, and enter the title of the new page you would like to create (ex: Adding a new field to a template). When you save your changes, a link will be generated (in red, since there is no content added yet), and if you click on the new link you will be taken to a new wiki page. Here you can add useful elements such as an overview of the process, challenges and considerations, snippets of code, and links to examples in the Git repository. I would also suggest providing a link to this discussion.

You can also find a few notes and suggestions on contributing Development Documentation here: https://www.qubit-toolkit.org/wiki/Code_Documentation_Guidelines

Please consider adding to our documentation - by doing so, you help build our user community into a stronger, more interactive environment, and you will undoubtedly help future developers find what they need to get started. In turn, this improves the software for everyone.

If you are interested in helping but unfamiliar/uncomfortable with the wiki format, I would also invite you to send me a word document (d...@artefactual.com), and I will make sure it gets added to the wiki.

Thanks again, and I'm glad to hear you've made such excellent progress.

Dan Gillean
Systems Analyst
Artefactual Systems, Inc.
http://www.artefactual.com | +1.604.527.2056


Prathmesh

unread,
Jan 30, 2013, 11:16:07 AM1/30/13
to qubi...@googlegroups.com, je...@artefactual.com
Hi Dan,

  I would like to contribute to the community and would consider documenting the "add new Fields" topic. I have other works waiting in the pipeline, so as soon as I find time I'll start doing this. I'll probably contact you then , if I need any help.

Thanks for the support !

-Prathmesh
Reply all
Reply to author
Forward
0 new messages