Menu

Make a CI field required.

2015-01-06
2015-01-07
  • Greg Sacrey

    Greg Sacrey - 2015-01-06

    Hi folks,

    I am struggling to make the status field for the PC class required. I have made sure the extension xml has for this field is stating null is not allowed. I have also changed the values.

    <field id="user-content-status" xsi:type="AttributeEnum" _delta="redefine">
    <values>
    <value>Deommissioned</value>
    <value>Delete</value>
    <value>Deployed</value>
    <value>Disposed</value>
    <value>In Inventory</value>
    <value>In Transit</value>
    <value>Ordered</value>
    <value>Reserved</value>
    <value>Return to IT</value>
    </values>
    <sql>status</sql>
    <default_value></default_value>
    <is_null_allowed>false</is_null_allowed></field>

    I am not sure beyond not allowing null how to make the field required in the GUI.

    Also can I make the default blank? Thus forcing the user to make a selection and not just saving it with a default?

    Thanks

    Greg

     
  • slade

    slade - 2015-01-06

    maybe <mandatory> or <must_prompt> in the attributes will help?</must_prompt></mandatory>

    eg.:

    <states>
      <state id="new">
        <flags>
          <attribute id="ref">
            <read_only/>
            <must_prompt/>
            <mandatory/> 
          </attribute>
         </flags>
       </state>
    </states>
    
     

    Last edit: slade 2015-01-06
  • Greg Sacrey

    Greg Sacrey - 2015-01-07

    The issue is that the parent class Physical Device needs to have it's null allowed value set to false.

    It is not sufficient to simply change the pc class. It does not overwrite the parent class.

     
  • Denis

    Denis - 2015-01-07

    Hmm, in this case you'll have to write a little bit of PHP code:

    Overload the method GetAttributeFlags(...) for the class PC and return the constant OPT_ATT_MADATORY if $sAttCode == 'status'

     
  • Greg Sacrey

    Greg Sacrey - 2015-01-07

    It works now by having the parent class status field set to not allow null.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.