@args Contact contact
@extends(/main.html)
@set(title: "Form")

<form action="@_u(save)" method="post">
    @authenticityToken()
    @{
        boolean nullContact = null == contact;
        Date date = null;
        if (!nullContact) date = contact.birthdate;
        String birthdate = (null == date) ? "" : play.templates.JavaExtensions.format(date, "yyyy-MM-dd");
    }@
    <input type="hidden" name="contact.id" value="@(nullContact ? "" : contact.id)">

    <p class="field">
        <label for="name">Name:</label>
        <input type="text" id="name" name="contact.name" value="@(nullContact ? "" : contact.name)">
        <span class="error">@error("contact.name")</span>
    </p>

    <p class="field">
        <label for="firstname">First name:</label>
        <input type="text" id="firstname" name="contact.firstname" value="@(nullContact ? "" : contact.firstname)">
        <span class="error">@error("contact.firstname")</span>
    </p>

    <p class="field">
        <label for="birthdate">Birth date:</label>
        <input type="text" id="birthdate" name="contact.birthdate" value="@birthdate">
        <span class="error">@error("contact.birthdate")</span>
    </p>

    <p class="field">
        <label for="email">Email:</label>
        <input type="text" id="email" name="contact.email" value="@(nullContact ? "" : contact.email)">
        <span class="error">@error("contact.email")</span>
    </p>

    <p class="buttons">
     	<a href="@_u(list())">Cancel</a> or <input type="submit" value="Save this contact" id="saveContact">
    </p>

    <script type="text/javascript" charset="${_response_encoding}">
        $("#birthdate").datepicker({dateFormat:'yy-mm-dd', showAnim:'fadeIn'})
	</script>
</form>
