cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

How to add textarea type input to a custom snap?

j_angelevski
Contributor III

Hi,

I am building a custom snap where some of the fields need to be a โ€˜textareaโ€™ type. Iโ€™ve been searching through the documentation but didnโ€™t find anything related to this.

Is there a way to make the field a text area ?
I am looking for something like the private/public keys in the account of a PGP Encrypt snap where the inputs are text area types.

On the image below, the input types are different from the โ€˜Key pasphraseโ€™ which is of an โ€˜inputโ€™ type but the private and public keys are of โ€˜text areaโ€™ type.
image

@ptaylor Any suggestions please ?

13 REPLIES 13

ptaylor
Employee
Employee

Yes: call .uiRowCount(int) when building the property.

Thank you, that works, however I am unable to properly parse the value from the field ?
Does it return a string or something else ?

Hereโ€™s what I have:

...
private static final String PRIVATE_KEY = "Private key";
private static final String PUBLIC_KEY = "Public key";
...
private String privateKey; // This is used to capture the value from the private key property
private String publicKey; // This is used to capture the value from the public key property

Then the defineProperties method:

...
        propertyBuilder.describe(PRIVATE_KEY, "Private key")
            .required()
            .uiRowCount(10)
            .add();
        
        propertyBuilder.describe(PUBLIC_KEY, "Public key")
            .uiRowCount(10)
            .add();
...

Then the configure method:

    @Override
    public void configure(PropertyValues propertyValues) {
        ...
        privateKey = propertyValues.get(PRIVATE_KEY);
        publicKey = propertyValues.get(PUBLIC_KEY);
        ...
    }

This is how the snap looks like with the properties:
image

However, when the pipeline is executed with the snap included, it returns the following error:

Snap has the following errors.
Please open the info box and edit the highlighted fields.
* Failure: Private key: asdasd is undefined.
Perhaps you meant: task, Base64, parseFloat, parseInt,
Reason: Snap failed unexpectedly and did not provide any reason,
Resolution: Check the spelling of the variable

Is it because .uiRowCount(int) returns a different type than String, so it is not able to parse it correctly in the configure() method ?

Please open the Pipeline Statistics, expand the details, copy the stack trace and paste it here.

do share the full body of the configure() method.