Skip to content

Conversation

@accognet
Copy link
Contributor

@accognet accognet commented Jun 12, 2025

use this delta with GetCurrentValue in place of Get and Vincent's example (in bug 7289) will work :

<?xml version="1.0" encoding="UTF-8"?>
<itop_design xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="3.1">
  <classes>
    <class id="Location" _created_in="itop-structure" _delta="must_exist">
      <fields>
        <field id="person_id" xsi:type="AttributeExternalKey" _delta="define">
          <sql>person_id</sql>
          <filter/>
          <dependencies>
            <attribute id="status"/>
          </dependencies>
          <is_null_allowed>true</is_null_allowed>
          <target_class>Person</target_class>
          <on_target_delete>DEL_AUTO</on_target_delete>
          <tracking_level>all</tracking_level>
        </field>
      </fields>
      <methods>
        <method id="GetAttributeFlags" _delta="define">
          <comment></comment>
          <static>false</static>
          <access>public</access>
          <code><![CDATA[public function GetAttributeFlags($sAttCode, &$aReasons = array(), $sTargetState = '')
{
	if (($sAttCode == 'person_id') && ($this->GetCurrentValue('status') == 'inactive'))
    {
       // Combine the new Flag with those impose by a parent class
       return(OPT_ATT_READONLY | parent::GetAttributeFlags($sAttCode, $aReasons, $sTargetState));
    }
    return parent::GetAttributeFlags($sAttCode, $aReasons, $sTargetState);
	}]]></code>
        </method>
      </methods>
      <presentation>
        <details >
          <items>
            <item id="person_id" _delta="define">
              <rank>100</rank>
            </item>
          </items>
        </details>
      </presentation>
    </class>
  </classes>
  <dictionaries>
  </dictionaries>
  <files>
   </files>
  <branding>
  </branding>
</itop_design>

@accognet accognet self-assigned this Jun 12, 2025
@accognet accognet added enhancement New feature or request internal Work made by Combodo labels Jun 12, 2025
@accognet accognet requested a review from rquetiez June 12, 2025 15:43
@accognet accognet changed the title N°7577 - Issue with GetAttributeFlags when Attributes are set to HIDDEN N°7289 - Read-only attribute, dynamically read-write, entry silently ignored on submission Jun 12, 2025
* this is used to check the current value in GetAttributeFlag function (useful to manage dynamic readonly attributes)
* @param $sAttr
*/
public function GetCurrentValue($sAttCode)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Method name too vague and comment are somewhat cryptic to me.
Need some dialog to find how to name and describe things.

* this is used to check if field has been modifed in GetAttributeFlag function (useful to manage dynamic readonly attributes)
* @param $sAttr
*/
public function IsModifiedValue($sAttCode)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Method name too vague and comment are somewhat cryptic to me.
Need some dialog to find how to name and describe things.

@accognet accognet force-pushed the feature/7577-GetAttributeFlags_Attributes_HIDDEN branch 2 times, most recently from 5ad63c5 to d13532d Compare September 22, 2025 13:37
@accognet accognet force-pushed the feature/7577-GetAttributeFlags_Attributes_HIDDEN branch from 456854d to 88c19e6 Compare October 2, 2025 09:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request internal Work made by Combodo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants