Customising Adding a New Field to a Form Person Form

Asked by ehr on 2008-11-03

Hi

Am trying to add a dependent combo box like the residence combo boxes and also a simple text field to a person form. I tried to follow the instructions on the customisation on this link
http://open.intrahealth.org/wiki/index.php/Customizing_iHRIS_Manage

and am not getting any luck. The confusing part 1) where to put the customised or subclass created for the iHRIS_Person class 2) where to find the config.inc.php. The closet I could find was /iHRIS/3.1/I2CE/I2CE_config.inc.php and when I added the two line I would get the error

Fatal error: Call to a member function search() on a non-object in /var/lib/iHRIS/3.1/I2CE/I2CE_config.inc.php on line 57

Has anybody been able to add new fields to the person form and is there an alternative way through the configure interface?

Regards

Chanda

Question information

Language:
English Edit question
Status:
Solved
For:
iHRIS Manage Edit question
Assignee:
No assignee Edit question
Solved by:
ehr
Solved:
2008-11-03
Last query:
2008-11-03
Last reply:
2008-11-03
ehr (chanda-lusakatimes) said : #1

Sorry I forgot to mention that am trying to tie a person to a facility and so the combo box I want to add to the form is for a faciltytype--> facility at the time of adding a person

Carl Leitner (litlfred) said : #2

The way to add custom classes is to add them into the search path. The easiest way to do this is to add in a search path for your site's configuration file. Let's suppose you were modifying the "Demo" site for manage. It's configuration file is found in:
    ihris-manage/sites/Demo/iHRIS-Manage-Demo.xml
You would simply need to add the lines:
    <path name='classes'>
         <value>./lib</value>
    </path>
where you see similar lines in the configuration file. Now, any classes you put in
     ihris-manage/sites/Demo/lib
would be found as long as you save the class called MyPerson in the file MyPerson.php

That being said, forms are special classes that don't necessarily exist. If you are just adding a field
to the iHRIS_Person class, you can do so without actually creating MyPerson class. Alot of information
about forms and fields are saved in the "Magic Data" which is defined in the various configuration files.
To see what is defined for iHRIS_Person, take a look at
    ihris-common/modules/Person/Person.xml
You may also want to turn on the "Magic Data Browser" module to get a better sense of how things
are laid out under the "Magic Data Path"
    /modules/forms
which contains all the information about forms and their fields. There are two important places to
look for in the Person.xml file, under the node <configurationGroup name='forms'> there is
a node <configurationGroup name='person'>. This has a sub-node which tells it that it should
use the class iHRIS_Person. If you look in the file:
   ihris-manage/iHRIS-Manage-Configuration.xml
you will find a simillar setup of nodes with the name='person' but this time className='iHRIS_ManagePerson'.
Since ihris-manage requires ihris-common, the value in iHRIS-Manage-Configuration.xml takes precedence
so that iHRIS_ManagePerson is used as the class for the form 'person'

Back in the Person.xml, there is also node <configurationGroup name='formClasses'> with a
subnode called <configurationGroup name='iHRIS_Person'>. Under this node you will see information about
the various fields that are provided by 'iHRIS_Person'. Similarly in iHRIS-Manage-Configuration.xml, you
will find a node <configurationGroup name='iHRIS_ManagePerson'> you will see that it "extends" iHRIS_Person
as well as adds a new field called 'password'.

Sorry that the documentation is lacking at the moment. Hopefully, this will give you some examples of what
you can add to your site configuration file to add in a simple text field to your Person form. You may want to take
a look at the customizations done for Zanzibar:
   https://code.launchpad.net/~ihris+zanzibar
   http://bazaar.launchpad.net/~ihris+zanzibar/ihris-manage/3.1/files
and Rwanda:
   https://code.launchpad.net/~ihris+rwanda/ihris-manage/rwanda
To see some example of make a site configuration file.

Making the dependent combo box is a little bit more difficult. Is the top drop down country? If so you may want
to look at the file
    lib/Zanzibar_Facility.php
in the Zanzibar customizations for some ideas. If not, give me some more context and I can help you out.

Cheers,
-carl

Carl Leitner (litlfred) said : #3

The way the system is set up now, a person is associated to a facility via the position that
they hold.

A bit more technically, a person=iHRIS_ManagePerson may be assigned a position -- the
form person_position=iHRIS_PersonPosition is a child form of person. Then the the
person_position formed is mapped via the field position to the form position=iHRIS_Position.
Then, the form position links to the facility=iHRIS_Facility form.

This way, as a person changes positions, their facility information is automatically updated.

Is there some reason that you need to associate a person to a facility regardless of the position
that they hold?

ehr (chanda-lusakatimes) said : #4

Hi Carl,

Thanks for the quick response. Am still kind of even more confused. Anyway yes the top drop down is country and I want the most drop down list to be facilty. SO I should have something like Country-->Region-->District-->FaciltyType-->Facility/Office on the person form

I tried to enable Magic Map, nothing shows up and am getting these warnings below the page.

<b>Warning</b>: array_merge() [<a href='function.array-merge'>function.array-merge</a>]: Argument #1 is not an array in <b>/var/lib/iHRIS/3.1/I2CE/modules/Admin/lib/I2CE_SwissConfigFactory.php</b> on line <b>643</b>

<b>Warning</b>: array_merge() [<a href='function.array-merge'>function.array-merge</a>]: Argument #2 is not an array in <b>/var/lib/iHRIS/3.1/I2CE/modules/Admin/lib/I2CE_SwissConfigFactory.php</b> on line <b>643</b>

Any idea why

Chanda

ehr (chanda-lusakatimes) said : #5

Hi Carl just seen your message after I made the post.I have looked at the position option and I think it is the better way to do it . Thanks

Chanda

Carl Leitner (litlfred) said : #6

Let me know if you need any further help. I believe that the warning messages is a bug that has already been fixed and will be a part of the next release. It is not a major issue.

-carl

Arfan (arfanafzaal) said : #7

hi,
I check and follow the steps to add a new filed but no luck on my side.
Can u tell me how i can add a Field in Add Person form(Like hobby ) i am using Windows version.