We use a molecular theory to study the thermodynamics of a weak-polyacid hydrogel film that is chemically grafted to a solid surface. We investigate the response of the material to changes in the pH and salt concentration of the buffer solution. Our results show that the pH-triggered swelling of the hydrogel film has a non-monotonic dependence on the acidity of the bath solution. At most salt concentrations, the thickness of the hydrogel film presents a maximum when the pH of the solution is increased from acidic values. The quantitative details of such swelling behavior, which is not observed when the film is physically deposited on the surface, depend on the molecular architecture of the polymer network. This swelling-deswelling transition is the consequence of the complex interplay between the chemical free energy (acid-base equilibrium), the electrostatic repulsions between charged monomers, which are both modulated by the absorption of ions, and the ability of the polymer network to regulate charge and control its volume (molecular organization). In the absence of such competition, for example, for high salt concentrations, the film swells monotonically with increasing pH. A deswelling-swelling transition is similarly predicted as a function of the salt concentration at intermediate pH values. This reentrant behavior, which is due to the coupling between charge regulation and the two opposing effects triggered by salt concentration (screening electrostatic interactions and charging/discharging the acid groups), is similar to that found in end-grafted weak polyelectrolyte layers. Understanding how to control the response of the material to different stimuli, in terms of its molecular structure and local chemical composition, can help the targeted design of applications with extended functionality. We describe the response of the material to an applied pressure and an electric potential. We present profiles that outline the local chemical composition of the hydrogel, which can be useful information when designing applications that pursue or require the absorption of biomolecules or pH-sensitive molecules within different regions of the film.