Hoppa till huvudinnehållet

Create Features with attributes from form elements that can be empty

Kommentarer

3 kommentarer

  • Stefan Schweigert

    Hi Jostein,

     

    I think there's a few options that you could try:

    1. Set all of the inputs in the form to be Required.
    2. After the form is submitted, check that values were entered using If statements and potentially assign default values.

     

    Your idea should work using the Add Item activity to an empty collection.

     

    Thanks, Stefan

    0
  • Permanently deleted user

    Go to any popular site with a registration form, and you will notice that they give you feedback when you don't enter your data in the format they are expecting. You'll get messages such as:

       "This field is required" (you can't leave this field blank)

       "Please enter your phone number in the format xxx-xxxx" (it enforces three numbers followed by a dash, followed by four numbers)

       "Please enter a valid e-mail address"

       "Your password needs to be between 8 and 30 characters long, and contain one uppercase letter, one symbol, and a number"

    This is called form validation — when you enter data, the web application checks it to see that the data is correct. If correct, the application allows the data to be submitted to the server and (usually) saved in a database; if not, it gives you an error message explaining what corrections need to be made. Form validation can be implemented in a number of different ways.

    https://writeversity.com

    0
  • Jostein Svegården

    Thanks for your answer, Kevin. This post was not about form validation, but about the best way to apply logic in the workflow allowing the possibillity to submit a form containing fields with no value set.

     

    I solved this by creating an empty dictionary with Create Value. Then, I run a check like e.g. if !!$form1.state.number1.value on each form element. If the form element has a content, use Evaluate Expression to add the attribute name and the value as a key-value pair to the dictionary that is used as input to CreateFeature.

     

    With more than 30 attributes in the destination feature class, it was a lot of work setting up all the IF-tests and expression evaluations. If someone has a better way to do this, please let me know

    0

Du måste logga in om du vill lämna en kommentar.