Jump to content

Truly conditional domain fields?


namhost

Recommended Posts

I found this which allows me to add a fields during domain configuration. I used this to add a dropdown where the user can select:
 - Company
 - Individual

I also have two other fields:
 - Company Name
 - Your Name

Using conditional "Conditional Requirements", i was able to get add the code below to public_html/resources/domains/additionalfields.php:

foreach ($domainExtensions as $domainExtension)
{
  $additionaldomainfields[$domainExtension][$legalTypeLabel] = array(
    "Name" => $legalTypeLabel,
    "Type" => "dropdown",
    "Options" => '1|Company,2|Individual',
    "Required" => true,
  );

  $additionaldomainfields[$domainExtension]["Company Name"] = array(
    "Name" => "Company Name",
    "Type" => "text",
    "Size" => "100",
    'Required' => [
      $legalTypeLabel => [1],
    ],
  );

  $additionaldomainfields[$domainExtension]["Your Name"] = array(
    "Name" => "Your Name",
    "Type" => "text",
    "Size" => "100",
    'Required' => [
      $legalTypeLabel => [2],
    ],
  );

}

This works great and gives me this (see attachment).

So the problems I have:

  • It's showing a * next to both fields - I expect it to only show the asterisk next to the field that is required. So therefore, at first it must show the one field as required, then the second
  • But ideally, I want the whole field hidden when it's not required.

So my questions:

  1. Is there a way to add custom javascript upon field generation that can handle the show and hide logic as needed?
  2. Or will I just have to add my own custom javascript somewhere else? And if so, where?

Thanks!

domain.png

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated