Skip to content

Add React component for country creation #1345

Open
@php-coder

Description

@php-coder

We need to port existing form for country creation to React. Here is the current code:

<form id="add-country-form" method="post" class="form-horizontal" action="info.html"
th:action="@{${ADD_COUNTRY_PAGE}}" th:object="${addCountryForm}">
<div class="form-group" th:classappend="${#fields.hasErrors('name') ? 'has-error' : ''}">
<label for="name" class="control-label col-sm-4">
<span th:remove="tag" th:text="#{t_name_in_english}">
Name (in English)
</span>
<span class="required_field">*</span>
</label>
<div class="col-sm-5">
<input id="name" type="text" class="form-control" required="required" th:field="*{name}" />
<!--/*/
<span id="name.errors" class="help-block" th:if="${#fields.hasErrors('name')}" th:each="error : ${#fields.errors('name')}" th:text="${error}"></span>
/*/-->
</div>
</div>
<div class="form-group" th:classappend="${#fields.hasErrors('nameRu') ? 'has-error' : ''}">
<label for="nameRu" class="control-label col-sm-4" th:text="#{t_name_in_russian}">
Name (in Russian)
</label>
<div class="col-sm-5">
<input id="nameRu" type="text" class="form-control" th:field="*{nameRu}" />
<!--/*/
<span id="nameRu.errors" class="help-block" th:if="${#fields.hasErrors('nameRu')}" th:each="error : ${#fields.errors('nameRu')}" th:text="${error}"></span>
/*/-->
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-4 col-sm-5">
<input type="submit" class="btn btn-primary" value="Add" th:value="#{t_add}" />
</div>
</div>
</form>

When a user submits data, we should POST it to /categories Also, we should handle&show related errors from a server.

As part of this task we should only create a React component. API call will be implemented in #1347 Unit and integration tests, will be added later.

Part of #1328

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions